In the general you can't extract metric distance measurements from a single image, unless you have extra information about the world. For example, if you know the world is planar (or you can detect the floor, which is a planar region), then you can estimate a homography.
A homography is a projective transformation between planes (3x3 matrix). Given the camera intrinsic calibration, you can decompose this plane-induced homography into a rotation and translation. The translation is up to scale. You can resolve this scale ambiguity by knowing the distance from the camera to the floor (plane).
Once you have the homography, you can detect objects that are not on the plane. The homography allows you warp the first image onto the second. Objects on the plane will align and will have a small error. Objects not on the plane will not align. This is called parallax.
One way to implement this could be
- Extract features from both images.
- Match the features, or track them.
- Estimate the homography using RANSAC.
- Decompose the homography into a rotation and translation using the calibration.
- Warp the first image onto the
second. Pixels with large errors are not on the floor and could be
obstacles.
Most of the building blocks are implemented in opencv (see http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html).
Good luck.
P.S. the homography decomposition will also give you the normal of the plane. But, since you are assuming this is the ground plane, we have the normal pointing in the up direction. A more precise solution can be accomplished in your calibration procedure. You can use a checkerboard target and estimate its pose. The pose will have a plane normal and distance to the camera.