diff --git a/openbr/plugins/landmarks.cpp b/openbr/plugins/landmarks.cpp index 4f25593..5114fbb 100644 --- a/openbr/plugins/landmarks.cpp +++ b/openbr/plugins/landmarks.cpp @@ -230,6 +230,9 @@ class DelaunayTransform : public UntrainableTransform QList mappedPoints; + dst.file = src.file; + qDebug() << dst.file.name; + for (int i = 0; i < validTriangles.size(); i++) { Eigen::MatrixXf srcMat(validTriangles[i].size(), 2); @@ -272,8 +275,8 @@ class DelaunayTransform : public UntrainableTransform bitwise_and(dst.m(),mask,overlap); for (int j = 0; j < overlap.rows; j++) { for (int k = 0; k < overlap.cols; k++) { - if (overlap.at(k,j) != 0) { - mask.at(k,j) = 0; + if (overlap.at(j,k) != 0) { + mask.at(j,k) = 0; } } } @@ -281,11 +284,13 @@ class DelaunayTransform : public UntrainableTransform bitwise_and(buffer,mask,output); + dst.m() += output; } - Rect boundingBox = boundingRect(mappedPoints.toVector().toStdVector()); - dst.file.appendRect(OpenCVUtils::fromRect(boundingBox)); + // Overwrite any rects + //Rect boundingBox = boundingRect(mappedPoints.toVector().toStdVector()); + //dst.file.setRects(QList() << OpenCVUtils::fromRect(boundingBox)); } } diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index 57cbf6f..4197b95 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -252,16 +252,12 @@ class CropRectTransform : public UntrainableTransform void project(const Template &src, Template &dst) const { dst = src; - QList rects = dst.file.rects(); + QList rects = src.file.rects(); for (int i=0;i < rects.size(); i++) { - QRectF rect = rects[i]; - - rect.setX(rect.x() + rect.width() * QtUtils::toPoint(widthCrop).x()); - rect.setY(rect.y() + rect.height() * QtUtils::toPoint(heightCrop).x()); - rect.setWidth(rect.width() * (1-QtUtils::toPoint(widthCrop).y())); - rect.setHeight(rect.height() * (1-QtUtils::toPoint(heightCrop).y())); - - dst.m() = Mat(dst.m(), OpenCVUtils::toRect(rect)); + rects[i].setX(rects[i].x() + rects[i].width() * QtUtils::toPoint(widthCrop).x()); + rects[i].setY(rects[i].y() + rects[i].height() * QtUtils::toPoint(heightCrop).x()); + rects[i].setWidth(rects[i].width() * (1-QtUtils::toPoint(widthCrop).y())); + rects[i].setHeight(rects[i].height() * (1-QtUtils::toPoint(heightCrop).y())); } dst.file.setRects(rects); }