Sunday, May 31, 2015

Measuring distance with 2 cameras


Before I even start showing the program and how it works I have to say that working with images is a little bit tricky since the intensity of the light would make that our images look different if the intensity change.

In order to keep light in only one intensity we decided to make a close black box so our images don’t change.






Once we made the box and install the cameras we are ready to use NI Vision Builder to measure the distance of a object. The principle of the program is simple, if we know the distance of the cameras view we can see how big or small an object is, keeping in mind that we have to calibrate the software in order to get good results.

In the next picture you can see a little drawing of the measuring distance based  on the distance of the camera view:



In the picture below you can see how we easily calculate the distance of the object, we used the a printed ruler as a based in order to calibrate the program. You can download the ruler in PDF format and the NI Vision Builder project at the bottom of the post.



After we know how we will me measuring the distance we have to calibrate the program in order to tell the that a specific amount of pixels represent a specific distance in the real world.

To do the calibration process we need to take a picture of everything set up and take one of the color planes in order to get a black and white picture before we move on into more details of the program.


First we have to choose the camera we'll be using like in the picture above.


This is the picture taken with the camera and you can see that it is in color, but remember we need it in black and white like in the picture below:



After we have calibrated the program we have to make it run and tell us the distance.
Here you can see some pictures of it.



To calculate the distance we used the following code:



Here you have a video of the measuring working:



You can download the files in this link:
File name: Distance_camera.zip
Version of NI Vision Builder 2013

No comments:

Post a Comment