33 #include <opencv/cxcore.h> 35 #ifndef ICL_HAVE_OPENCV_OLD_STYLE 37 #include <opencv2/core/core.hpp> 38 #include <opencv2/core/version.hpp> 40 #if defined(CV_VERSION_EPOCH) && (CV_VERSION_EPOCH > 2) 41 #define ICL_HAVE_OPENCV_3 42 #elif !defined(CV_VERSION_EPOCH) && (CV_VERSION_MAJOR > 2) 43 #define ICL_HAVE_OPENCV_3 49 #ifdef ICL_HAVE_OPENCV_3 50 #define ICL_OPENCV_VERSION_MAJOR CV_VERSION_MAJOR 51 #define ICL_OPENCV_VERSION_MINOR CV_VERSION_MINOR 53 #define ICL_OPENCV_VERSION_MAJOR CV_VERSION_EPOCH 54 #define ICL_OPENCV_VERSION_MINOR CV_VERSION_MAJOR 58 #if defined(ICL_HAVE_OPENCV_3) 59 #include "opencv2/calib3d/calib3d_c.h" 61 #elif ICL_OPENCV_VERSION_MINOR > 3 62 #include "opencv2/imgproc/types_c.h" 63 #include "opencv2/imgproc/imgproc_c.h" 64 #include "opencv2/calib3d/calib3d.hpp" 66 #error ICL requires at least OpenCV 2.4 153 int getChannels()
const;
157 T* getInterleavedData();
160 const T* getInterleavedData()
const;
166 inline int icl_get_cv_mat_type() {
172 template<>
inline int icl_get_cv_mat_type<int>() {
return CV_32SC1; }
175 template<>
inline int icl_get_cv_mat_type<float>() {
return CV_32FC1; }
178 struct CvMatDelOp :
public utils::DelOpBase{
181 if(m) cvReleaseMat(&m);
197 m( nrows * ncols > 0 ? cvCreateMat(nrows, ncols, icl_get_cv_mat_type<T>()) : 0, true){}
201 m(
size.getDim() > 0 ? cvCreateMat(
size.height,
size.width, icl_get_cv_mat_type<T>()) : 0, true){}
206 size(0,0),
m(other, takeOwnerShip){
209 CvSize
size = cvGetSize(other);
215 CvMat *
get() {
return m.get(); }
218 const CvMat *
get()
const {
return m.get(); }
228 if(
size == this->size)
return;
231 CvMat *
m = cvCreateMat(
size.height,
size.width, icl_get_cv_mat_type<T>());
239 inline bool isNull()
const {
return m.get() == 0; }
248 return CV_MAT_ELEM(*
m,T,y,x);
253 return CV_MAT_ELEM((const_cast<CvMat&>(*
m)),T,y,x);
263 std::cout <<
"CvMatWrapper of a " << s.height <<
" x " << s.width <<
" matrix:" <<
"\n";
265 for(
int y=0;y<s.height;++y){
266 for(
int x=0;x<s.width;++x){
267 str << m(y,x) << ((x == s.width-1) ?
"\n" :
" ");
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
static void delete_func(CvMat *m)
Definition: OpenCV.h:180
Very simply wrapper about the opencv C++ matrix type cv::Mat.
Definition: OpenCV.h:137
CvMat * get()
returns the current wrapped CvMat pointer
Definition: OpenCV.h:215
const T & operator()(int y, int x) const
index operator (const)
Definition: OpenCV.h:252
ICLCore_API std::ostream & operator<<(std::ostream &s, const format &f)
puts a string representation of format into the given stream
Mat4D32f Mat
Short typedef for 4D float matrices.
Definition: GeomDefs.h:90
ICLCore_API IplImage * img_to_ipl(const ImgBase *src, IplImage **dst=0, DepthPreference e=PREFERE_SRC_DEPTH)
Convert ICLimage to OpenCV IplImage.
CvMatWrapper(int nrows=0, int ncols=0)
Constructor, creates a CvMat with given dimensions.
Definition: OpenCV.h:195
Utility class that wraps around a CvMat of type CV_32FC1.
Definition: OpenCV.h:189
utils::Size size
current size
Definition: OpenCV.h:190
ICLCore_API IplImage * img_to_ipl_shallow(ImgBase *src, IplImage *dst=0)
Convert single channel ICLimage to OpenCV IplImage.
void operator=(const Img< T > &image)
assigns given image (channel 0 only)
Definition: OpenCV.h:221
prefer source depth
Definition: OpenCV.h:79
ICLCore_API ImgBase * ipl_to_img(CvArr *src, ImgBase **dst=0, DepthPreference e=PREFERE_SRC_DEPTH)
Convert OpenCV IplImage to ICLimage.
ICLCore_API ImgBase * mat_to_img(const ::cv::Mat *src, ImgBase *dstIn=0)
converts cv::Mat to ImgBase (internally the pixel data is type-converted if needed)
::cv::Mat mat
Definition: OpenCV.h:138
const utils::Size & getSize() const
returns the current size
Definition: OpenCV.h:242
Size class of the ICL.
Definition: Size.h:61
CvMatWrapper(const utils::Size &size)
Definition: OpenCV.h:199
depth getDepth()
getDepth<T> returns to depth enum associated to type T
ICLCore_API ::cv::Mat * img_to_mat(const ImgBase *src, ::cv::Mat *dst=0)
converts icl image into opencv's C++ image type cv::Mat (data is deeply copied)
std::string str(const T &t)
convert a data type into a string using an std::ostringstream instance
Definition: StringUtils.h:136
ICLCore_API CvMat * img_to_cvmat_shallow(const ImgBase *src, CvMat *dst=0)
Convert single channel ICLimage to OpenCV CvMat.
depth
determines the pixel type of an image (8Bit-int or 32Bit-float)
Definition: Types.h:60
utils::SmartPtrBase< CvMat, CvMatDelOp > m
Definition: OpenCV.h:191
Base class for Exception handling in the ICL.
Definition: Exception.h:42
ICLCore_API CvMat * img_to_cvmat(const ImgBase *src, CvMat *dst=0, int channel=0)
Copy single ICLimage channel to OpenCV single channel CvMat.
CvMatWrapper(CvMat *other, bool takeOwnerShip=false)
Constructor with given source matrix (wrappes around that)
Definition: OpenCV.h:205
bool isNull() const
returns whether a non-null pointer is wrapped
Definition: OpenCV.h:239
T & operator()(int y, int x)
index operator
Definition: OpenCV.h:247
int getDim() const
reutrns width*height
Definition: Size.h:211
Base class for reference counting smart-pointers.
Definition: SmartPtrBase.h:222
ICLQt_API ImgQ channel(const ImgQ &image, int channel)
picks a specific image channel
const CvMat * get() const
returns the current wrapped CvMat pointer (const)
Definition: OpenCV.h:218
void setSize(const utils::Size &size)
adapts the size (if necessary)
Definition: OpenCV.h:227
DepthPreference
Modes that define whether to prefer the source image's or the destination image's depth.
Definition: OpenCV.h:78
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
#define ICLCore_API
Definition: CompatMacros.h:174
prefer destination depth
Definition: OpenCV.h:80