Commit 05f974da0bfd8e4c7ffc45758d42a091d08b737c
1 parent
9bf09e4d
Convenience function to go between matrix and point list
Showing
2 changed files
with
15 additions
and
1 deletions
openbr/core/eigenutils.cpp
| ... | ... | @@ -95,3 +95,12 @@ MatrixXf removeRowCol(MatrixXf X, int row, int col) { |
| 95 | 95 | } |
| 96 | 96 | return Y; |
| 97 | 97 | } |
| 98 | + | |
| 99 | +MatrixXf pointsToMatrix(QList<QPointF> points) { | |
| 100 | + MatrixXf P(points.size(), 2); | |
| 101 | + for (int i = 0; i < points.size(); i++) { | |
| 102 | + P(i, 0) = points[i].x(); | |
| 103 | + P(i, 1) = points[i].y(); | |
| 104 | + } | |
| 105 | + return P; | |
| 106 | +} | ... | ... |
openbr/core/eigenutils.h
| ... | ... | @@ -29,9 +29,13 @@ void printEigen(Eigen::MatrixXd X); |
| 29 | 29 | void printEigen(Eigen::MatrixXf X); |
| 30 | 30 | void printSize(Eigen::MatrixXf X); |
| 31 | 31 | |
| 32 | -//Remove row and column from the matrix | |
| 32 | +//Remove row and column from the matrix: | |
| 33 | 33 | Eigen::MatrixXf removeRowCol(Eigen::MatrixXf X, int row, int col); |
| 34 | 34 | |
| 35 | +//Convert a point list into a matrix: | |
| 36 | +Eigen::MatrixXf pointsToMatrix(QList<QPointF> points); | |
| 37 | + | |
| 38 | + | |
| 35 | 39 | template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> |
| 36 | 40 | inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) |
| 37 | 41 | { |
| ... | ... | @@ -121,4 +125,5 @@ Eigen::MatrixBase<T> eigStd(const Eigen::MatrixBase<T>& x,int dim) |
| 121 | 125 | } |
| 122 | 126 | qFatal("A matrix can only have two dimensions"); |
| 123 | 127 | } |
| 128 | + | |
| 124 | 129 | #endif // EIGENUTILS_H | ... | ... |