Ask Your Question

Behrouz2000's profile - activity

2020-10-15 10:08:45 -0600 received badge  Popular Question (source)
2018-04-09 11:06:50 -0600 asked a question getting error trying to run canny method

getting error trying to run canny method Im trying to run a code that processes an image and runs a canny method. first

2018-04-06 08:32:13 -0600 received badge  Student (source)
2018-03-19 07:48:27 -0600 marked best answer Trying to implement contours method in Java

I have the following code trying to implement getContours in Java here is my code:

public class Contour {

     private static ArrayList<Rect> getContourArea() {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat color = Imgcodecs.imread("C:\\Users\\bheda\\Desktop\\Cat03.jpg");
        Mat gray = new Mat();
        Imgproc.cvtColor(color, gray, Imgproc.COLOR_BGR2GRAY);
        Mat binarized = new Mat();
        Imgproc.threshold(color, binarized, 100, 255, Imgproc.THRESH_BINARY);
        Mat hierarchy = new Mat();
        Mat image = color.clone();
        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
        Imgproc.findContours(image, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
        Rect rect = null;
        double maxArea = 300;
        ArrayList<Rect> arr = new ArrayList<Rect>();
        for (int i = 0; i < contours.size(); i++) {
            Mat contour = contours.get(i);
            double contourArea = Imgproc.contourArea(contour);
            if (contourArea > maxArea) {
                rect = Imgproc.boundingRect(contours.get(i));
                arr.add(rect);
            }
        }
        return arr;
    }
    public static void main(String args[]){
        // Load the library

        getContourArea();
    }   
}

    When I run this code I get the following 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_Impl, file C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\contours.cpp, line 199 Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\contours.cpp:199: error: (-210) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function cvStartFindContours_Impl ] at org.opencv.imgproc.Imgproc.findContours_1(Native Method) at org.opencv.imgproc.Imgproc.findContours(Imgproc.java:2245) at test.Contour.getContourArea(Contour.java:34) at test.Contour.main(Contour.java:51)

2018-03-19 07:48:27 -0600 received badge  Scholar (source)
2018-03-18 17:59:42 -0600 edited question Trying to implement contours method in Java

Trying to implement contours method in Java I have the following code trying to implement getContours in Java here is my

2018-03-18 17:58:30 -0600 asked a question Trying to implement contours method in Java

Trying to implement contours method in Java I have the following code trying to implement getContours in Java here is my

2018-03-18 09:10:05 -0600 received badge  Enthusiast
2018-03-16 18:10:09 -0600 asked a question Trying to turn doCanny into a get request with rest api

Trying to turn doCanny into a get request with rest api Im trying to turn doCanny into a GET request using rest api. I

2018-02-22 11:41:31 -0600 received badge  Editor (source)
2018-02-22 11:41:31 -0600 edited question trying to set up a service

trying to set up a service I am trying to set a method to a service in netbeans in Windows, and when I try and deploy an

2018-02-22 11:40:29 -0600 asked a question trying to set up a service

trying to set up a service I am trying to set a method to a service and when I try and deploy and test the service I get

2018-02-21 13:26:42 -0600 asked a question trying to do openCV edge detection with doCanny in Java and Eclipse

trying to do openCV edge detection with doCanny in Java and Eclipse I am trying to to do openCV edge detection with doCa