I know there already are some answers posted about this topic, but it's not very clear to me how to measure the distance between a camera and an object.
My goal:
I managed to track a red ball with color detection using OpenCV. Now I'm trying to point a laser in the middle of the red ball. The laser should always follow the red ball when it moves. I'm using a small servo motor to turn the laser.
I'm thinking if I can measure the distance between the object and the camera, I will be able to calculate the angle the servo needs to turn...
I tried to follow Cameron Lowell Palmer's post.
What I did:
I calibrated my Pi Camera V2
f_x : 463.64
f_y : 463.64
c_x : 319,50
c_y : 239.5
Native resolution = 3280 x 2464 (I think? I'm not sure how to find this...)
Focal length = 3.00mm (I think? I'm not sure how to find this...)
Then I should be able to measure my object size in pixels? I'm don't know how...
Could someone help me with this?