Camera To Object Distance Calculation Using Opencv And Python
Solution 1:
If the landing rectangle size is known/constant then it is doable
some data to prepare
Take image of the landing rectangle at known distance. Use your Microsoft Lifecam HD 3000 with the same setup as on the copter (or take it by itself) and compute/measure the rectangle size in pixels and store it. So you have:
xs0,ys0- rectangle size [px]d0- distance from camera image was taken [m]
take the image
Find the rectangle on it and try to project it as it was taken perpendicular to camera view axis. Then compute its size in pixels
xs,yscompute the distance
Use the triangle similarity

this image was done for this Q/A: Specifiyng speed from visual size which can be of help. So
his the rectangle size in pixels in each axiszis the distance from camera focus point
so rewritten to names above you get
dx=d0*xs/xs0[m]dy=d0*ys/ys0[m]
dxanddyshould be the same but if your image is not take perpendicular or have other distortions then they will be a bit different. So distance is average of it or min or max depends on safety reasons. For exampled=0.5*(dx+dy)[m]
[Notes]
The distances are measured from projection point of camera so if yo do not know its position take rectangle image from 2 known distances from known point and compute the focus position ...
Post a Comment for "Camera To Object Distance Calculation Using Opencv And Python"