1 | initial version |
I tend to do this as simply as I can, so this may not be exactly what you're looking for.
Use your camera distortion to undistort an image, and find known world points (say, the corners of the table) in the un-distorted image. Calculate the projection matrix from undistorted pixel to world xy location.
Find the center of mass of your target, run the pixel location through the undistortPoints function and apply the projection matrix. It should now be in real world xy coordinates.
I don't think there's a function that does what you're asking, necessarily. The image alone doesn't contain enough information to know how far away the object is, until you add that it's always at z =10 and the camera extrinsic is blah. It might be a good idea to add one at some point though, this comes up a lot.
2 | No.2 Revision |
I tend to do this as simply as I can, so this may not be exactly what you're looking for.
Use your camera distortion to undistort an image, and find known world points (say, the corners of the table) in the un-distorted image. Calculate the projection perspective matrix from undistorted pixel to world xy location.
Find the center of mass of your target, run the pixel location through the undistortPoints function and apply the projection perspective matrix. It should now be in real world xy coordinates.
I don't think there's a function that does what you're asking, necessarily. The image alone doesn't contain enough information to know how far away the object is, until you add that it's always at z =10 and the camera extrinsic is blah. It might be a good idea to add one at some point though, this comes up a lot.