IMP logo
IMP Reference Guide  2.7.0
The Integrative Modeling Platform
opencv_interface.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em2d/opencv_interface.h
3  * \brief Interface with OpenCV
4  * Copyright 2007-2017 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 || IMP_EM2D_HAS_OPENCV3
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 //! Prints a OpenCV matrix
38 IMPEM2DEXPORT void show(const cv::Mat &m, std::ostream &out = std::cout);
39 
40 //! Quick and dirty way of writing a OpenCV matrix to a Spider image
41 IMPEM2DEXPORT void write_matrix(cv::Mat &m, std::string name);
42 
43 //! Show a Mat_
44 template <typename T>
45 void show(const cv::Mat_<T> &m, std::ostream &out = std::cout) {
46  for (int i = 0; i < m.rows; ++i) {
47  for (int j = 0; j < m.cols; ++j) {
48  out << m(i, j) << " ";
49  }
50  out << std::endl;
51  }
52  out << std::endl;
53 }
54 
55 IMPEM2D_END_NAMESPACE
56 
57 #endif /* IMPEM2D_OPENCV_INTERFACE_H */
2D transformations. Copyright 2007-2017 IMP Inventors. All rights reserved.
void write_matrix(cv::Mat &m, std::string name)
Quick and dirty way of writing a OpenCV matrix to a Spider image.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.