IMP  2.0.1
The Integrative Modeling Platform
opencv_interface.h
Go to the documentation of this file.
1 /**
2  * \file opencv_interface.h
3  * \brief inteface with OpenCV
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5 */
6 
7 #ifndef IMPEM2D_OPENCV_INTERFACE_H
8 #define IMPEM2D_OPENCV_INTERFACE_H
9 
10 #include "IMP/em2d/em2d_config.h"
12 
13 #if IMP_EM2D_HAS_OPENCV22
14 #include "opencv2/core/core.hpp"
15 #include "opencv2/core/version.hpp"
16 #include "opencv2/imgproc/imgproc.hpp"
17 #include "opencv2/highgui/highgui.hpp"
18 #else
19 #include "opencv/cv.h"
20 #include "opencv/highgui.h"
21 #endif
22 
23 #include <iostream>
24 
25 IMPEM2D_BEGIN_NAMESPACE
26 
27 typedef cv::Mat_<double> cvDoubleMat;
28 typedef cv::MatIterator_<double> cvDoubleMatIterator;
29 typedef cv::MatConstIterator_<double> cvDoubleConstMatIterator;
30 
31 typedef cv::Mat_<int> cvIntMat;
32 typedef cv::MatIterator_<int> cvIntMatIterator;
33 
34 typedef cv::Point_<int> cvPixel;
35 typedef std::vector< cvPixel > cvPixels;
36 
37 
38 //! Prints a OpenCV matrix
39 IMPEM2DEXPORT void show(const cv::Mat &m,std::ostream &out = std::cout);
40 
41 //! Quick and dirty way of writing a OpenCV matrix to a Spider image
42 IMPEM2DEXPORT void write_matrix(cv::Mat &m,std::string name);
43 
44 
45 //! Show a Mat_
46 template<typename T>
47 void show(const cv::Mat_<T> &m,std::ostream &out = std::cout) {
48  for ( int i=0;i<m.rows;++i) {
49  for ( int j=0;j<m.cols;++j) {
50  out << m(i,j) << " ";
51  }
52  out << std::endl;
53  }
54  out << std::endl;
55 }
56 
57 
58 IMPEM2D_END_NAMESPACE
59 
60 #endif /* IMPEM2D_OPENCV_INTERFACE_H */