Closed pablo-souza closed 2 weeks ago
Describe the bug X and Y axis inversion when drawing a circle using the circle function
To reproduce
alternatives = //image gray = await cv.cvtColorAsync(alternatives, cv.COLOR_BGR2GRAY); blur = await cv.gaussianBlurAsync(gray, (3, 3), 0,); thresh = (await cv.thresholdAsync(blur, 150, 255, cv.THRESH_BINARY)).$2; final contornos = (await cv.findContoursAsync( thresh, cv.RETR_LIST, cv.CHAIN_APPROX_NONE)) .$1; for (var contour in contornos) { var area = cv.contourArea(contour); var perimeter = cv.arcLength(contour, true); var circularidade = 4 * 3.14159 * (area / (perimeter * perimeter)); if (0.7 < circularidade && circularidade <= 1.2){ var (center,radius) = cv.minEnclosingCircle(contour); int ratio = radius.toInt(); int x = center.x.toInt(); int y = center.y.toInt(); cv.circle( alternatives, cv.Point(x,y), ratio, cv.Scalar.red, ); cont++; } } return cv.imencode(".png", alternatives).$2;
Expected behavior Draw a circle around each alternative
Found behavior A single circle was drawn
Solution
alternatives = //image gray = await cv.cvtColorAsync(alternatives, cv.COLOR_BGR2GRAY); blur = await cv.gaussianBlurAsync(gray, (3, 3), 0,); thresh = (await cv.thresholdAsync(blur, 150, 255, cv.THRESH_BINARY)).$2; final contornos = (await cv.findContoursAsync( thresh, cv.RETR_LIST, cv.CHAIN_APPROX_NONE)) .$1; for (var contour in contornos) { var area = cv.contourArea(contour); var perimeter = cv.arcLength(contour, true); var circularidade = 4 * 3.14159 * (area / (perimeter * perimeter)); if (0.7 < circularidade && circularidade <= 1.2){ var (center,radius) = cv.minEnclosingCircle(contour); int ratio = radius.toInt(); int x = center.x.toInt(); int y = center.y.toInt(); cv.circle( alternatives, cv.Point(y,x), //inversion ratio, cv.Scalar.red, ); cont++; } } return cv.imencode(".png", alternatives).$2;
verified, will be fixed soon.
@pablo-souza This bug has been resolved in v1.3.2, you can upgrade now~
Describe the bug X and Y axis inversion when drawing a circle using the circle function
To reproduce
Expected behavior Draw a circle around each alternative
Found behavior A single circle was drawn
Solution