Commit bad6be38f35674222761a6696edd7946865bcee7
1 parent
a0bb95c7
Fix comments from pull request
Showing
4 changed files
with
13 additions
and
11 deletions
openbr/core/eigenutils.cpp
| ... | ... | @@ -137,3 +137,11 @@ Eigen::MatrixXf matrixToVector(const Eigen::MatrixXf matrix) { |
| 137 | 137 | return vector; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | +Eigen::MatrixXf toEigen(const Mat m) { | |
| 141 | + if (m.type() != CV_32F) | |
| 142 | + qFatal("Mat to Eigen Converstation only supports CV_32F"); | |
| 143 | + | |
| 144 | + Eigen::MatrixXf data(m.rows, m.cols); | |
| 145 | + return Eigen::Map<const Eigen::MatrixXf>(m.ptr<float>(), m.rows, m.cols); | |
| 146 | +} | |
| 147 | + | ... | ... |
openbr/core/eigenutils.h
| ... | ... | @@ -21,6 +21,8 @@ |
| 21 | 21 | #include <Eigen/Core> |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | +#include <opencv2/core/core.hpp> | |
| 25 | + | |
| 24 | 26 | void writeEigen(Eigen::MatrixXf X, QString filename); |
| 25 | 27 | void writeEigen(Eigen::MatrixXd X, QString filename); |
| 26 | 28 | void writeEigen(Eigen::VectorXd X, QString filename); |
| ... | ... | @@ -40,6 +42,9 @@ Eigen::MatrixXf removeRowCol(const Eigen::MatrixXf X, int row, int col); |
| 40 | 42 | Eigen::MatrixXf pointsToMatrix(const QList<QPointF> points, bool isAffine=false); |
| 41 | 43 | QList<QPointF> matrixToPoints(const Eigen::MatrixXf P); |
| 42 | 44 | |
| 45 | +//Convert cv::Mat to Eigen | |
| 46 | +Eigen::MatrixXf toEigen(const cv::Mat m); | |
| 47 | + | |
| 43 | 48 | template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> |
| 44 | 49 | inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) |
| 45 | 50 | { | ... | ... |
openbr/core/opencvutils.cpp
| ... | ... | @@ -336,14 +336,6 @@ bool OpenCVUtils::overlaps(const QList<Rect> &posRects, const Rect &negRect, dou |
| 336 | 336 | return false; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | -Eigen::MatrixXf OpenCVUtils::toEigen(Mat m) { | |
| 340 | - if (m.type() != CV_32F) | |
| 341 | - qFatal("Mat to Eigen Converstation only supports CV_32F"); | |
| 342 | - | |
| 343 | - Eigen::MatrixXf data(m.rows, m.cols); | |
| 344 | - return Eigen::Map<const Eigen::MatrixXf>(m.ptr<float>(), m.rows, m.cols); | |
| 345 | -} | |
| 346 | - | |
| 347 | 339 | QDataStream &operator<<(QDataStream &stream, const Mat &m) |
| 348 | 340 | { |
| 349 | 341 | // Write header | ... | ... |
openbr/core/opencvutils.h
| ... | ... | @@ -24,8 +24,6 @@ |
| 24 | 24 | #include <opencv2/core/core.hpp> |
| 25 | 25 | #include <assert.h> |
| 26 | 26 | |
| 27 | -#include <Eigen/Core> | |
| 28 | - | |
| 29 | 27 | namespace OpenCVUtils |
| 30 | 28 | { |
| 31 | 29 | // Test/write/display image |
| ... | ... | @@ -93,7 +91,6 @@ namespace OpenCVUtils |
| 93 | 91 | bool overlaps(const QList<cv::Rect> &posRects, const cv::Rect &negRect, double overlap); |
| 94 | 92 | float overlap(const cv::Rect &rect1, const cv::Rect &rect2); |
| 95 | 93 | float overlap(const QRectF &rect1, const QRectF &rect2); |
| 96 | - Eigen::MatrixXf toEigen(cv::Mat m); | |
| 97 | 94 | |
| 98 | 95 | int getFourcc(); |
| 99 | 96 | } | ... | ... |