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,3 +137,11 @@ Eigen::MatrixXf matrixToVector(const Eigen::MatrixXf matrix) { | ||
| 137 | return vector; | 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,6 +21,8 @@ | ||
| 21 | #include <Eigen/Core> | 21 | #include <Eigen/Core> |
| 22 | #include <assert.h> | 22 | #include <assert.h> |
| 23 | 23 | ||
| 24 | +#include <opencv2/core/core.hpp> | ||
| 25 | + | ||
| 24 | void writeEigen(Eigen::MatrixXf X, QString filename); | 26 | void writeEigen(Eigen::MatrixXf X, QString filename); |
| 25 | void writeEigen(Eigen::MatrixXd X, QString filename); | 27 | void writeEigen(Eigen::MatrixXd X, QString filename); |
| 26 | void writeEigen(Eigen::VectorXd X, QString filename); | 28 | void writeEigen(Eigen::VectorXd X, QString filename); |
| @@ -40,6 +42,9 @@ Eigen::MatrixXf removeRowCol(const Eigen::MatrixXf X, int row, int col); | @@ -40,6 +42,9 @@ Eigen::MatrixXf removeRowCol(const Eigen::MatrixXf X, int row, int col); | ||
| 40 | Eigen::MatrixXf pointsToMatrix(const QList<QPointF> points, bool isAffine=false); | 42 | Eigen::MatrixXf pointsToMatrix(const QList<QPointF> points, bool isAffine=false); |
| 41 | QList<QPointF> matrixToPoints(const Eigen::MatrixXf P); | 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 | template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> | 48 | template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> |
| 44 | inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) | 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,14 +336,6 @@ bool OpenCVUtils::overlaps(const QList<Rect> &posRects, const Rect &negRect, dou | ||
| 336 | return false; | 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 | QDataStream &operator<<(QDataStream &stream, const Mat &m) | 339 | QDataStream &operator<<(QDataStream &stream, const Mat &m) |
| 348 | { | 340 | { |
| 349 | // Write header | 341 | // Write header |
openbr/core/opencvutils.h
| @@ -24,8 +24,6 @@ | @@ -24,8 +24,6 @@ | ||
| 24 | #include <opencv2/core/core.hpp> | 24 | #include <opencv2/core/core.hpp> |
| 25 | #include <assert.h> | 25 | #include <assert.h> |
| 26 | 26 | ||
| 27 | -#include <Eigen/Core> | ||
| 28 | - | ||
| 29 | namespace OpenCVUtils | 27 | namespace OpenCVUtils |
| 30 | { | 28 | { |
| 31 | // Test/write/display image | 29 | // Test/write/display image |
| @@ -93,7 +91,6 @@ namespace OpenCVUtils | @@ -93,7 +91,6 @@ namespace OpenCVUtils | ||
| 93 | bool overlaps(const QList<cv::Rect> &posRects, const cv::Rect &negRect, double overlap); | 91 | bool overlaps(const QList<cv::Rect> &posRects, const cv::Rect &negRect, double overlap); |
| 94 | float overlap(const cv::Rect &rect1, const cv::Rect &rect2); | 92 | float overlap(const cv::Rect &rect1, const cv::Rect &rect2); |
| 95 | float overlap(const QRectF &rect1, const QRectF &rect2); | 93 | float overlap(const QRectF &rect1, const QRectF &rect2); |
| 96 | - Eigen::MatrixXf toEigen(cv::Mat m); | ||
| 97 | 94 | ||
| 98 | int getFourcc(); | 95 | int getFourcc(); |
| 99 | } | 96 | } |