Commit a83b5e97ec7f9398bb33378f80264cd20bb2b65f
1 parent
f0170475
Fixed Delaunay bug
Showing
2 changed files
with
14 additions
and
13 deletions
openbr/plugins/landmarks.cpp
| @@ -230,6 +230,9 @@ class DelaunayTransform : public UntrainableTransform | @@ -230,6 +230,9 @@ class DelaunayTransform : public UntrainableTransform | ||
| 230 | 230 | ||
| 231 | QList<Point2f> mappedPoints; | 231 | QList<Point2f> mappedPoints; |
| 232 | 232 | ||
| 233 | + dst.file = src.file; | ||
| 234 | + qDebug() << dst.file.name; | ||
| 235 | + | ||
| 233 | for (int i = 0; i < validTriangles.size(); i++) { | 236 | for (int i = 0; i < validTriangles.size(); i++) { |
| 234 | Eigen::MatrixXf srcMat(validTriangles[i].size(), 2); | 237 | Eigen::MatrixXf srcMat(validTriangles[i].size(), 2); |
| 235 | 238 | ||
| @@ -272,8 +275,8 @@ class DelaunayTransform : public UntrainableTransform | @@ -272,8 +275,8 @@ class DelaunayTransform : public UntrainableTransform | ||
| 272 | bitwise_and(dst.m(),mask,overlap); | 275 | bitwise_and(dst.m(),mask,overlap); |
| 273 | for (int j = 0; j < overlap.rows; j++) { | 276 | for (int j = 0; j < overlap.rows; j++) { |
| 274 | for (int k = 0; k < overlap.cols; k++) { | 277 | for (int k = 0; k < overlap.cols; k++) { |
| 275 | - if (overlap.at<uchar>(k,j) != 0) { | ||
| 276 | - mask.at<uchar>(k,j) = 0; | 278 | + if (overlap.at<uchar>(j,k) != 0) { |
| 279 | + mask.at<uchar>(j,k) = 0; | ||
| 277 | } | 280 | } |
| 278 | } | 281 | } |
| 279 | } | 282 | } |
| @@ -281,11 +284,13 @@ class DelaunayTransform : public UntrainableTransform | @@ -281,11 +284,13 @@ class DelaunayTransform : public UntrainableTransform | ||
| 281 | 284 | ||
| 282 | bitwise_and(buffer,mask,output); | 285 | bitwise_and(buffer,mask,output); |
| 283 | 286 | ||
| 287 | + | ||
| 284 | dst.m() += output; | 288 | dst.m() += output; |
| 285 | } | 289 | } |
| 286 | 290 | ||
| 287 | - Rect boundingBox = boundingRect(mappedPoints.toVector().toStdVector()); | ||
| 288 | - dst.file.appendRect(OpenCVUtils::fromRect(boundingBox)); | 291 | + // Overwrite any rects |
| 292 | + //Rect boundingBox = boundingRect(mappedPoints.toVector().toStdVector()); | ||
| 293 | + //dst.file.setRects(QList<QRectF>() << OpenCVUtils::fromRect(boundingBox)); | ||
| 289 | } | 294 | } |
| 290 | } | 295 | } |
| 291 | 296 |
openbr/plugins/regions.cpp
| @@ -252,16 +252,12 @@ class CropRectTransform : public UntrainableTransform | @@ -252,16 +252,12 @@ class CropRectTransform : public UntrainableTransform | ||
| 252 | void project(const Template &src, Template &dst) const | 252 | void project(const Template &src, Template &dst) const |
| 253 | { | 253 | { |
| 254 | dst = src; | 254 | dst = src; |
| 255 | - QList<QRectF> rects = dst.file.rects(); | 255 | + QList<QRectF> rects = src.file.rects(); |
| 256 | for (int i=0;i < rects.size(); i++) { | 256 | for (int i=0;i < rects.size(); i++) { |
| 257 | - QRectF rect = rects[i]; | ||
| 258 | - | ||
| 259 | - rect.setX(rect.x() + rect.width() * QtUtils::toPoint(widthCrop).x()); | ||
| 260 | - rect.setY(rect.y() + rect.height() * QtUtils::toPoint(heightCrop).x()); | ||
| 261 | - rect.setWidth(rect.width() * (1-QtUtils::toPoint(widthCrop).y())); | ||
| 262 | - rect.setHeight(rect.height() * (1-QtUtils::toPoint(heightCrop).y())); | ||
| 263 | - | ||
| 264 | - dst.m() = Mat(dst.m(), OpenCVUtils::toRect(rect)); | 257 | + rects[i].setX(rects[i].x() + rects[i].width() * QtUtils::toPoint(widthCrop).x()); |
| 258 | + rects[i].setY(rects[i].y() + rects[i].height() * QtUtils::toPoint(heightCrop).x()); | ||
| 259 | + rects[i].setWidth(rects[i].width() * (1-QtUtils::toPoint(widthCrop).y())); | ||
| 260 | + rects[i].setHeight(rects[i].height() * (1-QtUtils::toPoint(heightCrop).y())); | ||
| 265 | } | 261 | } |
| 266 | dst.file.setRects(rects); | 262 | dst.file.setRects(rects); |
| 267 | } | 263 | } |