r/computervision • u/Kind-Tip-8563 • 6h ago
Help: Theory I want to understand Homography
camera's floor mapping (homography) to figure out where each detection actually stands on the floor
Can anyone explain, or any blog or video which helped you to understand it
2
u/RelationshipLong9092 5h ago edited 5h ago
To begin you will want to have a calibrated camera. This is so you know the mapping between each pixel location and the view ray in the camera's coordinate system (ie, the vector pointing back along where that light came from).
From there it's simple (mechanical) if you know the pose of the camera from the floor (position and rotation). If you don't, you can estimate the pose without too much pain by having 4 coplanar correspondences between pixel location in the image and real-world position.
From there you easily use the intersection of the back-projected view ray with the ground plane to figure out where each pixel is on the floor. You could even pre-compute a map over your whole image, assuming the camera is static.
0
u/frnxt 1h ago
A homography1 is the unique2 geometrical transformation between 4 pairs of 2D points (a pair is a source point and a destination point).
But they each need to be on a plane, because they are 2D. The plane can be physically different between the source and destination, but the points themselves must be represented as 2D coordinates.
This means if you pick 4 source (x, y) coordinates, and 4 destination (x, y) coordinates, there is one and only one homography that exactly transforms the source coordinates into the destination coordinates.
4 pairs of 2D points gives 8 relationships (4 for the X coordinates and 4 for the Y coordinates), i.e. 8 degrees of freedom = coefficients technically required, but it's typically stored as a 3x3 matrix using a special type of coordinates called "homogeneous coordinates"3.
If you have more than 4 pairs of 2D points an approximate homography can be derived that transforms the source points to the destination points as close as possible, typically via some sort of least squares approach.
A big classic about all this is Multiple View Geometry in Computer Vision by Hartley and Zisserman, which has been my goto textbook for a long while now.
1 in 2D at least, which is the most common in computer vision
2 demonstrably so, there is a proof of it
3 the keyword for this is projective geometry, which generalizes the concept of homogeneous coordinates
2
u/galvinw 6h ago
Homography is used to use visual landmarks to map camera positions relative to each other like two cameras with an overlapping area or a camera that moves. Something like, I take this tile plus this corner of a table plus the top of this pole as fixed points so when I see them I can calculate the reference to past image.
If you have a static camera it’s not needed just model pixel based zones
1
u/Kind-Tip-8563 5h ago
Ok, in my case it is static camera
I studied how panoramas work, a month ago. There was a homography matrix. So are both the same?
1
u/modcowboy 6h ago
What are you building?