Commit 532103f3def63c955e02a9ce1ea6a7c7b6cbe85c
1 parent
b02b39c2
Fixes based on code review
Showing
1 changed file
with
4 additions
and
7 deletions
openbr/plugins/landmarks.cpp
| @@ -169,7 +169,7 @@ class ProcrustesAlignTransform : public Transform | @@ -169,7 +169,7 @@ class ProcrustesAlignTransform : public Transform | ||
| 169 | aspectRatio = 0; | 169 | aspectRatio = 0; |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | - MatrixXf getRotation(MatrixXf ref, MatrixXf sample) const { | 172 | + static MatrixXf getRotation(MatrixXf ref, MatrixXf sample) { |
| 173 | MatrixXf R = ref.transpose() * sample; | 173 | MatrixXf R = ref.transpose() * sample; |
| 174 | JacobiSVD<MatrixXf> svd(R, ComputeFullU | ComputeFullV); | 174 | JacobiSVD<MatrixXf> svd(R, ComputeFullU | ComputeFullV); |
| 175 | R = svd.matrixU() * svd.matrixV(); | 175 | R = svd.matrixU() * svd.matrixV(); |
| @@ -177,7 +177,7 @@ class ProcrustesAlignTransform : public Transform | @@ -177,7 +177,7 @@ class ProcrustesAlignTransform : public Transform | ||
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | //Converts x y points in a single vector to two column matrix | 179 | //Converts x y points in a single vector to two column matrix |
| 180 | - MatrixXf vectorToMatrix(MatrixXf vector) const { | 180 | + static MatrixXf vectorToMatrix(MatrixXf vector) { |
| 181 | int n = vector.rows(); | 181 | int n = vector.rows(); |
| 182 | MatrixXf matrix(n / 2, 2); | 182 | MatrixXf matrix(n / 2, 2); |
| 183 | for (int i = 0; i < n / 2; i++) { | 183 | for (int i = 0; i < n / 2; i++) { |
| @@ -188,7 +188,7 @@ class ProcrustesAlignTransform : public Transform | @@ -188,7 +188,7 @@ class ProcrustesAlignTransform : public Transform | ||
| 188 | return matrix; | 188 | return matrix; |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | - MatrixXf matrixToVector(MatrixXf matrix) const { | 191 | + static MatrixXf matrixToVector(MatrixXf matrix) { |
| 192 | int n2 = matrix.rows(); | 192 | int n2 = matrix.rows(); |
| 193 | MatrixXf vector(n2 * 2, 1); | 193 | MatrixXf vector(n2 * 2, 1); |
| 194 | for (int i = 0; i < n2; i++) { | 194 | for (int i = 0; i < n2; i++) { |
| @@ -276,7 +276,7 @@ class ProcrustesAlignTransform : public Transform | @@ -276,7 +276,7 @@ class ProcrustesAlignTransform : public Transform | ||
| 276 | } | 276 | } |
| 277 | p = vectorToMatrix(p); | 277 | p = vectorToMatrix(p); |
| 278 | 278 | ||
| 279 | - //Nomralize translation | 279 | + //Normalize translation |
| 280 | p.col(0) = p.col(0) - MatrixXf::Ones(p.rows(),1) * (p.col(0).sum() / p.rows()); | 280 | p.col(0) = p.col(0) - MatrixXf::Ones(p.rows(),1) * (p.col(0).sum() / p.rows()); |
| 281 | p.col(1) = p.col(1) - MatrixXf::Ones(p.rows(),1) * (p.col(1).sum() / p.rows()); | 281 | p.col(1) = p.col(1) - MatrixXf::Ones(p.rows(),1) * (p.col(1).sum() / p.rows()); |
| 282 | 282 | ||
| @@ -287,9 +287,6 @@ class ProcrustesAlignTransform : public Transform | @@ -287,9 +287,6 @@ class ProcrustesAlignTransform : public Transform | ||
| 287 | MatrixXf R = getRotation(referenceShape, p); | 287 | MatrixXf R = getRotation(referenceShape, p); |
| 288 | p = p * R.transpose(); | 288 | p = p * R.transpose(); |
| 289 | 289 | ||
| 290 | - for (int i = 0; i < p.rows(); i++) { | ||
| 291 | - } | ||
| 292 | - | ||
| 293 | //Translate and scale into output space and store in output list | 290 | //Translate and scale into output space and store in output list |
| 294 | QList<QPointF> procrustesPoints; | 291 | QList<QPointF> procrustesPoints; |
| 295 | for (int i = 0; i < p.rows(); i++) | 292 | for (int i = 0; i < p.rows(); i++) |