Mat and List<Point> conversions

1,793 views
Skip to first unread message

Stergios

unread,
Sep 21, 2011, 1:53:35 PM9/21/11
to android-opencv
I try to follow this tutorial
http://opencv.itseez.com/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography

I am using the Java wrapper and i managed to convert much of the code
to the java equivalent however i have some problems at this point


Mat H = findHomography( obj, scene, CV_RANSAC );

//-- Get the corners from the image_1 ( the object to be
"detected" )
std::vector<Point2f> obj_corners(4);
obj_corners[0] = cvPoint(0,0); obj_corners[1] =
cvPoint( img_object.cols, 0 );
obj_corners[2] = cvPoint( img_object.cols, img_object.rows );
obj_corners[3] = cvPoint( 0, img_object.rows );
std::vector<Point2f> scene_corners(4);

perspectiveTransform( obj_corners, scene_corners, H);

i can get the Mat H but i cannot use the
Core.perspectiveTransform( <Mat>, <Mat> ) because i cannot create the
approprite Matrx from the object_corners that is a List<Point>.

So my problem is how to convert a List<Point> to a Mat




Andrey Pavlenko

unread,
Sep 22, 2011, 3:12:46 AM9/22/11
to android...@googlegroups.com
List<Point> pts = ...
Mat pts_mat = org.opencv.utils.Converters.vector_Point2f_to_Mat(pts);

Stergios K

unread,
Sep 22, 2011, 8:16:58 AM9/22/11
to android...@googlegroups.com
Thank you very much Andrey i totally missed that



Reply all
Reply to author
Forward
0 new messages