Reputation: 385
I'm using Xamarin.OpenCV.Droid,
and I'd like to convert an array of Point
s to Mat
.
I know Converters
class has several methods that seem adequate for the conversion.
However, I totally don't understand the difference between Vector_Point_to_Mat
and Vector_Point2f_to_Mat
.
Both methods receive Point[]
as an arg and return Mat
.
What's the difference?
Which is more adequate to execute Imgproc.GetPerspectiveTransform
for example?
https://github.com/NAXAM/opencv-android-binding/
Upvotes: 1
Views: 306
Reputation: 74174
In the C++ version, there are int, int64, float, and double based Point types.
typedef Point_<int> Point2i;
typedef Point_<int64> Point2l;
typedef Point_<float> Point2f;
typedef Point_<double> Point2d;
In the Java-based OpenCV, there is only Point
(double-based), but the Java vector_Point(|2d|2f)_to_Mat APIs will create a Mat with the corresponding CvType (via the native/C++ call) :
CvType.CV_32SC2 (vector_Point_to_Mat)
CvType.CV_32FC2 (vector_Point2f_to_Mat)
CvType.CV_64FC2 (vector_Point2d_to_Mat)
For info on types: see this SO: What's the difference between cvtype values in OPENCV?
public static Mat vector_Point_to_Mat(List<Point> pts) {
return vector_Point_to_Mat(pts, CvType.CV_32S);
}
public static Mat vector_Point2f_to_Mat(List<Point> pts) {
return vector_Point_to_Mat(pts, CvType.CV_32F);
}
public static Mat vector_Point2d_to_Mat(List<Point> pts) {
return vector_Point_to_Mat(pts, CvType.CV_64F);
}
Upvotes: 3