1 | initial version |
Plane containing the balls: Constrain in this problem would be that you need the plane containing the balls perpendicular to axis of your camera. If that is not the case, the detected distance between your balls will always be less than actual distance.
Distance of objects from camera: One case would be having the plane containing the ball at a fixed distance from your camera. In this case conversion of distance in pixels to cm would be possible by calibrating your camera. This can be done by placing your objects at a known distance from each other (say 10 cm) and calculating the distance between them in pixels say (500 pixels). Now while calculating distance would be simple mathematics. If pixel distance is 300, then actual distance is: x = 300 * 10 / 500. In this case it wont be necessary to know the size of object
Second case would be having the plane containing the ball at variable distance from your camera. In this case you should know the size of object before hand. Knowing the size of object, would help calibrate the camera. Say a object which (in your case : ball) is say 5 cm in real world is represented using 30 pixels, then the distance between object which is 300 pixels on image can be calculate as (300 * 5 / 30). Thus knowing the object size is key factor if the plane containing the objects is variable.
Hope this helps you!
2 | No.2 Revision |
The problem can be divided in two parts:
Plane containing the balls: Constrain in this problem would be that you need the plane containing the balls perpendicular to axis of your camera. If that is not the case, the detected distance between your balls will always be less than actual distance.
Distance of objects from camera: One case would be having the plane containing the ball at a fixed distance from your camera. In this case conversion of distance in pixels to cm would be possible by calibrating your camera. This can be done by placing your objects at a known distance from each other (say 10 cm) and calculating the distance between them in pixels say (500 pixels). Now while calculating distance would be simple mathematics. If pixel distance is 300, then actual distance is: x = 300 * 10 / 500. In this case it wont be necessary to know the size of object
Second case would be having the plane containing the ball at variable distance from your camera. In this case you should know the size of object before hand. Knowing the size of object, would help calibrate the camera. Say a object which (in your case : ball) is say 5 cm in real world is represented using 30 pixels, then the distance between object which is 300 pixels on image can be calculate as (300 * 5 / 30). Thus knowing the object size is key factor if the plane containing the objects is variable.
Hope this helps you!