how can i compute the angle of an object in front of my camera? The resolution of my camera is 1280x1024, the focal length of my lens is 8mm and the pixel size of each pixel on the CMOS is 4.8 micrometer. Surely it must be possible to compute the angle from that. Also i computed the distance of the object to the camera and everything is on one level. So only the X coordinate is interesting, right?
I am using OpenCV and Python for the processing.
My idea was to use the focal length of the lens in combination with the X-Offset of the detected object from the sensor middle, but i do get weird angles from that.
This is the code for the angle estimation:
first the point X coordinate, second the width of the whole sensor (1280 pixels * 4.8um) in mm, third the focal length in mm.
angle = (pointInterpolatedX*6.144)/8
Could anybody give me some help here? Thanks!
Also, i had a look at this topic here, but i can't quite understand it. I have a lot more informations about my camera and also my object can only move in 2 Dimensions and not three. So there might be a clever way of estimating its position on the ground in front of the camera. Does OpenCV have any function i could use for that?