Ask Your Question
0

about MatOfPoint2f

asked 2013-03-19 22:51:54 -0600

zhang13404 gravatar image

updated 2013-03-20 06:00:10 -0600

opencv4android 2.4.4

befort i use Imgproc.approxPolyDP, I want to convert Mat to MatOfPoint2f;

Mat initialImg = Highgui.imread("/sdcard/card.jpg", 0);
MatOfPoint2f matOfPoint2f=new MatOfPoint2f(initialImg);

then I got the error:

03-20 10:35:57.825: E/AndroidRuntime(25073): java.lang.IllegalArgumentException: Incomatible Mat The error line is:

MatOfPoint2f matOfPoint2f=new MatOfPoint2f(initialImg);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-03-20 06:08:28 -0600

berak gravatar image

updated 2013-03-20 06:23:58 -0600

you can't approximate an Image with a polygon, you need to to find some contours first.

it's not a matter of converting Mat types, you're missing some processing steps.

to do it, you need to:

  1. binarize your (grayscale) image using threshold, compare or Canny
  2. findContours() in the binary image , probably filter out stuff you don't want
  3. now you can approxpoly those contours
edit flag offensive delete link more

Comments

at first,thank you for you answer~ yes, you are right. in fact, I have done a similar deal with, such as canny, but after using canny, i have still Mat types, still need to convert Mat to MatOfPoint2f, what should i do?

zhang13404 gravatar imagezhang13404 ( 2013-03-20 21:13:34 -0600 )edit

Oh! I get it. I overlooked after findContours() i have List<MatOfPoint>. thank you very much~!

zhang13404 gravatar imagezhang13404 ( 2013-03-20 21:35:18 -0600 )edit

Question Tools

Stats

Asked: 2013-03-19 22:51:54 -0600

Seen: 1,257 times

Last updated: Mar 20 '13