Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unsupported format or combination of formats while contours

I am trying below code to get contours of images.

 // Load images to compare
    Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    System.out.println(img1);

    ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Imgproc.findContours(img1, contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);
    Imgproc.findContours(img2, contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);

    System.out.println("contours=="+contours.size());

But getting below error:-

OpenCV Error: Unsupported format or combination of formats ([Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only) in cvStartFindContours, file /tmp/opencv3-20161019-20369-7r0q5p/modules/imgproc/src/contours.cpp, line 219
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: /tmp/opencv3-20161019-20369-7r0q5p/modules/imgproc/src/contours.cpp:219: error: (-210) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function cvStartFindContours
]