Hi Ginto8,
I found Miss Daisy Code, regarding the distance calculation:
Quote:
double x = square.getX() + (square.getWidth() / 2);
x = (2 * (x / size.width())) - 1;
double y = square.getY() + (square.getHeight() / 2);
y = -((2 * (y / size.height())) - 1);
double range = (kTopTargetHeightIn-kCameraHeightIn)/Math.tan((y*kVerticalFOVDeg/2.0 + kCameraPitchDeg)*Math.PI/180.0);
|
As I understood from their code, they have a fixed camera, and by the normalized Y center of mass position of the target, they find out how far they are from the target (their distance is horizontal and not a diagonal distance). Their camera is at kCameraPitchDeg and when Y changes from -1 to 1, they can know the actual angle of the target relative to the camera (In other words, this angle is the angle between the line which connects the target and the camera and a line parallel to the ground). They know height and an angle – so they can find the horizontal distance from the target!
Am I right?
If so, another question arises. We calculated the distance when the target is in the middle of the image because the lens of the camera makes stuff look bigger when it’s far from the camera’s center, and then the height of the target was bigger (in pixels) than it should’ve been.
They used only the center of Y of the target, so maybe it makes this lens distortion negligible?
If I was right about my understanding of this code, and the lens disorder is not affecting much, I think it might be a better solution for calculating distance.
Have someone from here tried this solution and it worked without major errors like the other method for calculating distance??
Thank you all very much!