fixed bug in pad detection (area calculation was wrong)

This commit is contained in:
Steffen Vogel 2015-01-29 14:29:22 +01:00
parent 698749a8bc
commit 2cd3df2d69

View file

@ -63,7 +63,13 @@ Result * PadDetect::applyInternal(Image *img)
case PadDetect::AREA: {
Pad pad = minAreaRect(contour);
double areaContour = contourArea(contour);
Mat mask = Mat::zeros(m.size(), m.type());
std::vector<std::vector<Point>> ctrs = { contour };
fillPoly(mask, ctrs, Scalar(1, 1, 1));
mask = mask.mul(m);
double areaContour = countNonZero(mask);
double areaRect = pad.getArea();
if (areaContour / areaRect > areaRatio)