Please help me,
I have a problem for Convex Hull on Android. I am using Java and OpenCV 2.3 .
Before I did it in Java, I did it in C ++ with Visual Studio 2008.
This code can successfully work in C ++.
Now I want to convert it from C ++ to Java on Android. And I found an error like "force close" when I run it on the Android SDK simulator.
This is my C ++ code:
vector<vector<Point> > contours; vector<Vec4i> hierarchy; findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) ); drawing = Mat::zeros( canny_output.size(), CV_64F );
And this is my Android code:
Mat hierarchy = new Mat(img_canny.rows(),img_canny.cols(),CvType.CV_8UC1,new Scalar(0)); List<Mat> contours =new ArrayList<Mat>(); List<Mat> hull = new ArrayList<Mat>(contours.size()); drawing = Mat.zeros(img_canny.size(), im_gray); Imgproc.findContours(img_dilasi, contours, hierarchy,Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0, 0)); for(int i=0; i<contours.size(); i++){ Imgproc.convexHull(contours.get(i), hull.get(i), false); } for(int i=0; i<contours.size(); i++){ Imgproc.drawContours(drawing, hull, i, new Scalar(255.0, 255.0, 255.0), 5); }
For your information, I made a small modification to Convex Hull in my code. I fill the color inside the outline .
Can anyone help me solve my problem?
I am very grateful for your help.