user4134476
user4134476

Reputation: 385

What's the difference between Vector_Point_to_Mat and Vector_Point2f_to_Mat

I'm using Xamarin.OpenCV.Droid,

and I'd like to convert an array of Points 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

Answers (1)

SushiHangover
SushiHangover

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);
}

re: https://github.com/opencv/opencv/blob/2c6f1ab57d4250ee46e32d1b51c056431965b470/modules/java/generator/src/java/org/opencv/utils/Converters.java#L37

Upvotes: 3

Related Questions