KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cv_optical_flow.h
Go to the documentation of this file.
1 /* =========================================================================== *
2  |
3  | Copyright (c) 1994-2011 by Kobus Barnard (author)
4  |
5  | Personal and educational use of this code is granted, provided that this
6  | header is kept intact, and that the authorship is not misrepresented, that
7  | its use is acknowledged in publications, and relevant papers are cited.
8  |
9  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10  |
11  | Please note that the code in this file has not necessarily been adequately
12  | tested. Naturally, there is no guarantee of performance, support, or fitness
13  | for any particular task. Nonetheless, I am interested in hearing about
14  | problems that you encounter.
15  |
16  | Author: Denis Gorbunov, Jinyan Guan
17  * =========================================================================== */
18 
19 /* $Id: cv_optical_flow.h 17393 2014-08-23 20:19:14Z predoehl $ */
20 
21 #ifndef CV_OPTICAL_FLOW_H_
22 #define CV_OPTICAL_FLOW_H_
23 
24 #include <vector>
25 #include <m_cpp/m_vector.h>
26 #include <m_cpp/m_matrix.h>
27 #include <i_cpp/i_image.h>
28 
29 #ifdef KJB_HAVE_OPENCV
31 #endif
32 namespace kjb
33 {
34 namespace opencv
35 {
40 #define CV_LKFLOW_PYR_A_READY 1
41 #define CV_LKFLOW_PYR_B_READY 2
42 #define CV_LKFLOW_INITIAL_GUESSES 4
43 
44 #define DEFAULT_WINDOW_HEIGHT 15
45 #define DEFAULT_WINDOW_WIDTH 15
46 #define DEFAULT_MAX_LEVEL 3
47 
48 
53 #ifdef KJB_HAVE_OPENCV
54 
55 struct CV_optical_flow_feature
56 {
57  size_t id;
58  Vector value;
59  CV_optical_flow_feature() {}
60 
61  CV_optical_flow_feature(size_t id_, const Vector& value_)
62  : id(id_), value(value_)
63  {}
64 };
65 
66 class CV_optical_flow_pyr_lk
67 {
68 public:
69  // Constructor
70  CV_optical_flow_pyr_lk()
71  : window_height(DEFAULT_WINDOW_HEIGHT),
72  window_width(DEFAULT_WINDOW_WIDTH),
73  max_level(DEFAULT_MAX_LEVEL),
74  criteria(CV_term_criteria()),
75  flags(0)
76  {}
77 
78  CV_optical_flow_pyr_lk
79  (
80  int window_height_,
81  int window_width_,
82  int max_level_,
83  const CV_term_criteria& criteria_,
84  int flags_
85  ) :
86  window_height(window_height_),
87  window_width(window_width_),
88  max_level(max_level_),
89  criteria(criteria_),
90  flags(flags_)
91  {}
92 
93  std::vector<Vector> get_next_features
94  (
95  const Image& prev_image,
96  const Image& next_image,
97  const std::vector<Vector>& prev_features
98  ) const;
99 
103  std::vector<CV_optical_flow_feature> get_next_features
104  (
105  const Image& prev_image,
106  const Image& next_image,
107  const std::vector<CV_optical_flow_feature>& prev_features
108  ) const;
109 
110  std::vector<CV_optical_flow_feature> convert_to_optical_flow_feature
111  (
112  const std::vector<Vector> & features
113  );
114 
118  void write_features
119  (
120  const std::string& out_fname,
121  const std::vector<Vector>& cur_features,
122  const std::vector<Vector>& next_features
123  ) const;
124 
128  void write_features
129  (
130  const std::string& out_fname,
131  const std::vector<CV_optical_flow_feature>& cur_features,
132  const std::vector<CV_optical_flow_feature>& next_features
133  ) const;
134 
135 private:
136 
140  int window_height;
141  int window_width;
142 
147  int max_level;
148 
153  CV_term_criteria criteria;
154 
161  int flags;
162 };
163 #endif
164 
165 
166 } // namespace opencv
167 } // namespace kjb
168 
169 #endif /* OPTICAL_FLOW_H_ */
Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionalit...
#define DEFAULT_MAX_LEVEL
Definition: cv_optical_flow.h:46
#define DEFAULT_WINDOW_HEIGHT
Definition: cv_optical_flow.h:44
#define DEFAULT_WINDOW_WIDTH
Definition: cv_optical_flow.h:45
end get the endpoints of the long edges and an image of the long edges for id
Definition: APPgetLargeConnectedEdges.m:96
Code for a wrapper class around the C struct KJB_Image.
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...