Ask Your Question
0

Measuring the dimension of object with OpenCV.

asked 2016-02-02 09:36:34 -0600

BrahimMaster gravatar image

Hello . I have a project for the detection of object and measuring dimensions .so i use traincascade for the detection but i have one problem .For this instruction vector<rect> faces .so what is faces.x faces.y ,face.width ,and faces.height . i can't understand the difference between them . so if we have des dimensions of the object can i measur the distance object camera ? thanks a lot

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-02-02 16:00:54 -0600

Tetragramm gravatar image

The x and y variables are the location of the top left corner in the image. Width and Height are just that. So a rectangle from (100,120) to (200,250) would be x = 100, y = 120, width = 100, height = 130.

To get the distance, you have to know the relationship between number of pixels and distance. Fortunately, this is easy to get. Take a picture of something with a known dimension, at a known distance. Use the known object size and the known distance to calculate the field of view of the camera. The important number is actually instantaneous field of view, which is FOV/number of pixels. You probably have two FOVs, one for vertical, and one for horizontal. The IFOV is probably the same for both directions though.

Once you have the IFOV and the known object sizes, you can use them to get the object distance.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-02-02 09:36:34 -0600

Seen: 714 times

Last updated: Feb 02 '16