Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Android: cannot draw the interior of contours

Hello,

I don't know if this is a bug or a mistake by me but i cannot draw the interior of the contours of an image. My input image is this:

image description

I am using the Android version of OpenCv and the following code snippet for contour detection:

Mat canny = new Mat();
Imgproc.Canny(in_grayImg, canny, 100, 200);

List<MatOfPoint> contours = new LinkedList<MatOfPoint>();
Mat hierarchy = new Mat();
Imgproc.findContours(canny, contours, hierarchy, Imgproc.RETR_CCOMP,
            Imgproc.CHAIN_APPROX_SIMPLE);

These are the detected contours drawn with

Imgproc.drawContours(canny, contours, -1, new Scalar(255));

image description

According to the API using the drawContours with a negative thickness value draws the interior of the contours. However the following code to draw the contours results in the same image as before:

Imgproc.drawContours(canny, contours, -1, new Scalar(255), -1);

image description

I also tried using the detected hierarchy but the result is unchanged:

Imgproc.drawContours(canny, contours, -1, new Scalar(255), -1, 8, hierarchy, 2, new Point(0, 0));

image description

I really don't know what I am doing wrong and it seems to me that a negative thickness value is simply ignored.

Thanks in advance and best regards,

Josef

Android: cannot draw the interior of contours

Hello,

I don't know if this is a bug or a mistake by me but i cannot draw the interior of the contours of an image. My input image is this:

image description

I am using the Android version of OpenCv and the following code snippet for contour detection:

Mat canny = new Mat();
Imgproc.Canny(in_grayImg, canny, 100, 200);

List<MatOfPoint> contours = new LinkedList<MatOfPoint>();
Mat hierarchy = new Mat();
Imgproc.findContours(canny, contours, hierarchy, Imgproc.RETR_CCOMP,
            Imgproc.CHAIN_APPROX_SIMPLE);

These are the detected contours drawn with

Imgproc.drawContours(canny, contours, -1, new Scalar(255));

image description

According to the API using the drawContours with a negative thickness value draws the interior of the contours. However the following code to draw the contours results in the same image as before:

Imgproc.drawContours(canny, contours, -1, new Scalar(255), -1);

image description

I also tried using the detected hierarchy but the result is unchanged:

Imgproc.drawContours(canny, contours, -1, new Scalar(255), -1, 8, hierarchy, 2, new Point(0, 0));

image description

I really don't know what I am doing wrong and it seems to me that a negative thickness value is simply ignored.

Thanks in advance and best regards,

Josef