Java API generator: implementation of vector<Point> support
authorAndrey Pavlenko <no@email>
Sat, 16 Jul 2011 08:25:05 +0000 (08:25 +0000)
committerAndrey Pavlenko <no@email>
Sat, 16 Jul 2011 08:25:05 +0000 (08:25 +0000)
modules/java/src/cpp/utils.cpp

index 89d4d2c..557bb44 100644 (file)
@@ -65,12 +65,23 @@ void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)
 //vector_Point\r
 void Mat_to_vector_Point(Mat& mat, vector<Point>& v_point)\r
 {\r
+       v_point.clear();\r
+       \r
+       if(mat.type()!= CV_32SC2 || mat.rows!=1)\r
+               return;\r
+\r
+       for(int i=0; i<mat.cols; i++)\r
+               v_point.push_back( Point( mat.at< Vec<int, 2> >(0, i) ) );\r
+\r
     return;\r
 }\r
 \r
 \r
 void vector_Point_to_Mat(vector<Point>& v_point, Mat& mat)\r
 {\r
+       mat.create(1, v_point.size(), CV_32SC2);\r
+       for(int i=0; i<v_point.size(); i++)\r
+               mat.at< Vec<int, 2> >(0, i) = Vec<int, 2>(v_point[i].x, v_point[i].y);\r
     return;\r
 }\r
 \r