DNB5brims
DNB5brims

Reputation: 30598

How to convert the Point2f to UIImage's position?

I use a UIImage to convert to a cvMat based on this question:

how to convert from cvMat to UIImage in objective-c?

And according to the tutorial of Open CV, I do some object detection:

http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography

They get a std::vector<Point2f> scene_corners(4); for the position of the object found. It allow me to draw back on the cvMat, but I would like to convert it back to a UIImage's position. How can I do it? Because if I simply use the Point2f, the position is all wrong, I think it must be some way to translate it, but I don't have any clues to start with. Thanks.

Upvotes: 0

Views: 180

Answers (1)

OpenCV and UIImage both use the same coordinate system, with origin at the top left of the image. So, you just have to scale the points using the height and width of your UIImageView. Have you already done this? If so, it will be nice to post a screenshot to see how the pixels are offset.

Upvotes: 1

Related Questions