KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cv_util.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: Jinyan Guan
17  * =========================================================================== */
18 
19 /* $Id: cv_util.h 14164 2013-04-01 06:54:46Z jguan1 $ */
20 
21 #ifndef CV_UTIL_H_
22 #define CV_UTIL_H_
23 
24 #ifdef KJB_HAVE_OPENCV
25 #include <wrap_opencv_cpp/cv.h>
26 #endif
27 
28 #include <i_cpp/i_image.h>
29 #include <m_cpp/m_matrix.h>
30 
31 #define CV_TERMCRIT_ITER 1
32 #define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER
33 #define CV_TERMCRIT_EPS 2
34 
35 #define DEFAULT_MAX_ITER 30
36 #define DEFAULT_MAX_EPSILON 0.1
37 
38 namespace kjb
39 {
40 namespace opencv
41 {
42 
44 {
45  // A combination of CV_ITERMCRIT_ITER and CV_TERMCRIT_EPS
46  int type;
47 
48  // Maximum number of iterations
49  int max_iter;
50 
51  // Required accuracy
52  double epsilon;
53 
54  // Constructor
59  {}
60 
61  inline CV_term_criteria
62  (
63  int type_,
64  int max_iter_,
65  double epsilon_
66  ) :
67  type(type_),
68  max_iter(max_iter_),
69  epsilon(epsilon_)
70  {}
71 
72 };
73 
74 #ifdef KJB_HAVE_OPENCV
75 
78 inline CvTermCriteria to_opencv(CV_term_criteria criteria)
79 {
80  CvTermCriteria cv_criteria;
81  cv_criteria.type = criteria.type;
82  cv_criteria.max_iter = criteria.max_iter;
83  cv_criteria.epsilon = criteria.epsilon;
84 
85  return cv_criteria;
86 }
87 
91 //cv::Ptr<IplImage> to_opencv(const Image& image);
92 
96 cv::Ptr<IplImage> to_opencv_gray(const Image& image);
97 
101 cv::Ptr<IplImage> to_opencv_gray(const Matrix& matrix);
102 
106 cv::Mat to_opencv(const Image& img);
107 
113 cv::Mat to_opencv(const Matrix& matrix);
114 
120 Matrix opencv_to_kjb(const cv::Mat& cv_mat);
121 
122 #endif
123 } // namespace opencv
124 } // namespace kjb
125 
126 #endif
Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionalit...
Definition: cv_util.h:43
#define DEFAULT_MAX_EPSILON
Definition: cv_util.h:36
#define CV_TERMCRIT_EPS
Definition: cv_util.h:33
int type
Definition: cv_util.h:46
double epsilon
Definition: cv_util.h:52
float ** matrix(long nrl, long nrh, long ncl, long nch)
Definition: nr.cpp:76
#define CV_TERMCRIT_ITER
Definition: cv_util.h:31
#define DEFAULT_MAX_ITER
Definition: cv_util.h:35
Code for a wrapper class around the C struct KJB_Image.
int max_iter
Definition: cv_util.h:49
CV_term_criteria()
Definition: cv_util.h:55