7 #ifndef IMPEM2D_OPENCV_INTERFACE_H
8 #define IMPEM2D_OPENCV_INTERFACE_H
10 #include <IMP/em2d/em2d_config.h>
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"
19 #include "opencv/cv.h"
20 #include "opencv/highgui.h"
24 #include <boost/serialization/access.hpp>
25 #include <boost/serialization/binary_object.hpp>
27 IMPEM2D_BEGIN_NAMESPACE
29 typedef cv::Mat_<double> cvDoubleMat;
30 typedef cv::MatIterator_<double> cvDoubleMatIterator;
31 typedef cv::MatConstIterator_<double> cvDoubleConstMatIterator;
33 typedef cv::Mat_<int> cvIntMat;
34 typedef cv::MatIterator_<int> cvIntMatIterator;
36 typedef cv::Point_<int> cvPixel;
37 typedef std::vector<cvPixel> cvPixels;
40 IMPEM2DEXPORT
void show(
const cv::Mat &m, std::ostream &out = std::cout);
43 IMPEM2DEXPORT
void write_matrix(cv::Mat &m, std::string name);
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) <<
" ";
60 namespace serialization {
61 template<
class Archive>
62 inline void serialize(Archive &ar, cv::Mat &m,
const unsigned int) {
66 if (Archive::is_saving::value) {
70 continuous = m.isContinuous();
72 ar & rows & cols & type & continuous;
74 if (Archive::is_loading::value) {
75 m.create(rows, cols, type);
79 size_t data_size = rows * cols * m.elemSize();
80 boost::serialization::binary_object mat_data(m.data, data_size);
83 size_t row_size = cols * m.elemSize();
84 for (
int i = 0; i < rows; ++i) {
85 boost::serialization::binary_object row_data(m.ptr(i), row_size);
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.