This project finds real objects dimensions from their images using OpenCV Java using two methods - Reference Method and Stereo Method.
Code for this project is available on my GitHub:
https://github.com/shyamabhuvanendran/VirtualRuler_CV
6. HOW IMAGE IS FORMED?
Intrinsic Matrix = [ -f/sx 0 Ox
0 -f/sy Oy
0 0 0 ]
7. IMPLEMENTATION
Reference Object Method
Uses an object of known dimensions in the image.
Stereo Method
Uses two images of the same scene captured from
different positons in space.
The distance and orientation of camera at the two
positions is known.
8. APPROACH – REFERENCE METHOD
1. Preprocess the image
2. Find Extrinsic Matrix
3. Compute Z
4. Compute other object dimensions
16. 3. Compute Z
Project the world coordinates of the reference object
using Extrinsic Matrix.
Z is the same for all objects on the same plane as
reference object.
APPROACH – REFERENCE METHOD
17. 4. Compute other object dimensions.
Get the pixel coordinates of the minimum bounding
rectangles.
Re-project to camera coordinate system using inverse
intrinsic matrix.
Multiply by the computed Z.
Use distance formula to calculate dimensions.
APPROACH – REFERENCE METHOD
19. 1. Preprocess the images.
Grayscale
Blur
Detect edges
Find Contours
Get vertices of the minimum bounding rectangles.
APPROACH – STEREO METHOD
20. 2. Compute Z
Compute disparity of the two images using compute()
method of StereoSGBM class.
Compute Z using the below formula:
Z = Focal-Length * Baseline-Distance
Disparity
APPROACH – STEREO METHOD
21. 3. Compute camera coordinates.
Re-project the minimum bounding rectangle vertices of
the objects to camera coordinate system using inverse
intrinsic matrix.
Multiply the coordinates by the computed Z.
4. Calculate object dimensions.
Calculate object dimensions using distance formula.
APPROACH – STEREO METHOD
26. Reference Object Method:
1. Could determine dimensions with high accuracy for objects
lying on the same X-Y plane as the reference object.
2. The accuracy dropped as the object distance from the
reference object increases along the Z-axis.
Stereo Method:
1. Could determine the Z accurately.
2. The accuracy dropped in cases where the object detection
method used couldn’t get the exact vertices of the objects in
the image.
OBSERVATIONS