OpenCV - obtain the normal of a detected image within a video frame
I have a project which applies SURF(Speeded Up Robust Features) in order to detected a given picture within another set of pictures or within a live stream video from my Web Camera.
It works similar to what is illustrated within this video :
The thing is that the rectangle which frames the reference picture is in 2D, and I want to obtain its position with respect to 3D. Basically this is the normal of the image.
Is there a way of obtaining the normal of the image based on the determined rectangle?
The rectangle is something like :
Top Left = (x1, y1) Top Right = (x2, y1) Bottom Left = (x3, y3) Bottom Right = (x4, y4)
Is there a way of obtaining the normal of the image with respect to the frame based on this coordinates?
You can obtain the 3D transform that matches your set of input points to your detected rectangle:
cv::Mat in = 0, 0 w, 0 0, h cv::Mat ou = x1, y1 x2, y2 x3, y3 cv::Mat mat = cv::getAffineTransform(in, ou);
And then use this matrix to transform the normal of the input image:
[row, col] = mat * [0, 0, 1]