Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you're almost there !

when using Imgproc.RETR_EXTERNAL with findContours() , it expects white fg and black background (and you got it the other way round), so instead of :

Imgproc.cvtColor(outputImageMat, outputMat, Imgproc.COLOR_BGR2GRAY); // not needed, it's already CV_8U

do:

Core.bitwise_not(outputImageMat, outputMat); // invert white / black

or simply invert the comparison:

Core.compare(firstMat, secondMat, outputImageMat, Core.CMP_GT);

you're almost there !

when using Imgproc.RETR_EXTERNAL with findContours() , it expects white fg and black background (and you got it the other way round), so instead of :either:

Imgproc.cvtColor(outputImageMat, outputMat, Imgproc.COLOR_BGR2GRAY); // not needed, it's already CV_8U

do:

Core.bitwise_not(outputImageMat, Core.bitwise_not(outputMat, outputMat); // invert white / black

or simply invert the comparison:

Core.compare(firstMat, secondMat, outputImageMat, Core.CMP_GT);