Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Java how to access or convert List<matofpoint> to a list of points (x,y)

What can I do with a List<matofpoint> to get a list for example with a coordinates of the contours?

So this is the photo I want to detect the lines from: image description

when I print the contour list it gives me a long text which i can't find out what to do with that like :

[Mat [ 21CV_32SC2, isCont=true, isSubmat=false,nativeObj=0xd2095b0, dataAddr=0xd24d410 ], Mat [ 31CV_32SC2, isCont=true, isSubmat=false, nativeObj=0xd209620, dataAddr=0xd1c88e0 ]

Can I use it somehow or is there any other method to take the contours from the image and have the coordinates or something like that?

So I have an image of line, already processed through the filters like grayscale, canny edge detector and I'm doing a function findContours and a draw contours:

 Imgproc.findContours(mat, aContours,aHierarchy, Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);` 
 Imgproc.drawContours(mat,aContours,-1, color,CONTOUR_LINE_THICKNESS);

and I want a coordinates of a found contours from the findcontours function. Could you help me?

click to hide/show revision 2
No.2 Revision

updated 2015-09-09 04:39:37 -0600

berak gravatar image

OpenCV Java how to access or convert List<matofpoint> to a list of points (x,y)

What can I do with a List<matofpoint> to get a list for example with a coordinates of the contours?

So this is the photo I want to detect the lines from: image description

when I print the contour list it gives me a long text which i can't find out what to do with that like :

>  [Mat [ 21CV_32SC2, 2*1*CV_32SC2, isCont=true, isSubmat=false,nativeObj=0xd2095b0, dataAddr=0xd24d410 ],
 >  Mat [ 31CV_32SC2, 3*1*CV_32SC2, isCont=true, isSubmat=false, nativeObj=0xd209620, dataAddr=0xd1c88e0 ]

]

Can I use it somehow or is there any other method to take the contours from the image and have the coordinates or something like that?

So I have an image of line, already processed through the filters like grayscale, canny edge detector and I'm doing a function findContours and a draw contours:

 Imgproc.findContours(mat, aContours,aHierarchy, Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);` 
 Imgproc.drawContours(mat,aContours,-1, color,CONTOUR_LINE_THICKNESS);

and I want a coordinates of a found contours from the findcontours function. Could you help me?