1 | initial version |
Hi,
You should first read about the homography concept, for example : https://en.wikipedia.org/wiki/Homography_%28computer_vision%29 or http://people.scs.carleton.ca/~c_shu/Courses/comp4900d/notes/homography.pdf
Basically, the matrix H contains the geometric transformation to pass from a view to another view assuming a planar surface in space.
In the tutorial, after the matching of the keypoints, you estimate the homography H using a RANSAC method (a robust method to estimate the homography without (trying to not) taking care of the possible outliers) with :
> Mat H = findHomography( obj, scene, CV_RANSAC );
So :
perspectiveTransform( obj_corners, scene_corners, H);
will just calculate the coordinates of the box corners in the current vew / scene to draw the bounding box.
2 | No.2 Revision |
Hi,
You should first read about the homography concept, for example : https://en.wikipedia.org/wiki/Homography_%28computer_vision%29 or http://people.scs.carleton.ca/~c_shu/Courses/comp4900d/notes/homography.pdf
Basically, the matrix H contains the geometric transformation to pass from a view to another view assuming a planar surface in space.
In the tutorial, after the matching of the keypoints, you estimate the homography H using a RANSAC method (a robust method to estimate the homography without (trying to not) taking care of the possible outliers) with :
> Mat H = findHomography( obj, scene, CV_RANSAC );
So :
perspectiveTransform( obj_corners, scene_corners, H);
will just calculate the coordinates of the box corners in the current vew / scene to draw the bounding box.
Edit: The function calculates for each corners (if I am not wrong) :
w = H_31 * obj_corners[i].x + H_32 * obj_corners[i].y + H_33 * 1
scene_corners[i].x = (H_11 * obj_corners[i].x + H_12 * obj_corners[i].y + H_13 * 1) / w
scene_corners[i].y = (H_21 * obj_corners[i].x + H_22 * obj_corners[i].y + H_23 * 1) / w
3 | No.3 Revision |
Hi,
You should first read about the homography concept, for example : https://en.wikipedia.org/wiki/Homography_%28computer_vision%29 or http://people.scs.carleton.ca/~c_shu/Courses/comp4900d/notes/homography.pdf
Basically, the matrix H contains the geometric transformation to pass from a view to another view assuming a planar surface in space.
In the tutorial, after the matching of the keypoints, you estimate the homography H using a RANSAC method (a robust method to estimate the homography without (trying to not) taking care of the possible outliers) with :
> Mat H = findHomography( obj, scene, CV_RANSAC );
So :
perspectiveTransform( obj_corners, scene_corners, H);
will just calculate the coordinates of the box corners in the current vew view / scene to draw the bounding box.
Edit: The function calculates for each corners (if I am not wrong) :
w = H_31 * obj_corners[i].x + H_32 * obj_corners[i].y + H_33 * 1
scene_corners[i].x = (H_11 * obj_corners[i].x + H_12 * obj_corners[i].y + H_13 * 1) / w
scene_corners[i].y = (H_21 * obj_corners[i].x + H_22 * obj_corners[i].y + H_23 * 1) / w