Commit 7828854c authored by jsxyhelu's avatar jsxyhelu Committed by Alexander Alekhin

Merge pull request #12206 from jsxyhelu/3.4

find innercircle of contour by using pointPolygonTest: (#12206)
parent 492ef145
......@@ -50,7 +50,8 @@ int main( void )
}
double minVal, maxVal;
minMaxLoc( raw_dist, &minVal, &maxVal );
Point maxDistPt; // inscribed circle center
minMaxLoc(raw_dist, &minVal, &maxVal, NULL, &maxDistPt);
minVal = abs(minVal);
maxVal = abs(maxVal);
......@@ -76,10 +77,11 @@ int main( void )
}
}
}
circle(drawing, maxDistPt, (int)maxVal, Scalar(255,255,255));
/// Show your results
imshow( "Source", src );
imshow( "Distance", drawing );
imshow( "Distance and inscribed circle", drawing );
waitKey();
return 0;
......
......@@ -72,10 +72,11 @@ class PointPolygonTest {
}
}
drawing.put(0, 0, drawingData);
Imgproc.circle(drawing, res.maxLoc, (int)res.maxVal, new Scalar(255, 255, 255), 2, 8, 0);
/// Show your results
HighGui.imshow("Source", src);
HighGui.imshow("Distance", drawing);
HighGui.imshow("Distance and inscribed circle", drawing);
HighGui.waitKey();
System.exit(0);
......
......@@ -29,7 +29,7 @@ for i in range(src.shape[0]):
for j in range(src.shape[1]):
raw_dist[i,j] = cv.pointPolygonTest(contours[0], (j,i), True)
minVal, maxVal, _, _ = cv.minMaxLoc(raw_dist)
minVal, maxVal, _, maxDistPt = cv.minMaxLoc(raw_dist)
minVal = abs(minVal)
maxVal = abs(maxVal)
......@@ -46,6 +46,7 @@ for i in range(src.shape[0]):
drawing[i,j,1] = 255
drawing[i,j,2] = 255
cv.circle(drawing,maxDistPt, int(maxVal),tuple(255,255,255), 1, cv.LINE_8, 0)
cv.imshow('Source', src)
cv.imshow('Distance', drawing)
cv.imshow('Distance and inscribed circle', drawing)
cv.waitKey()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment