kl3m3n's blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Stereovision in Labview based on corresponding point pairs

Klemen
Active Participant

Hello,

the following post is dedicated to calculation of 3D coordinates using the stereo concept for a scene point that is seen by both cameras. The Labview stereo vision library basically lacks the capability (or maybe I should say a function) to extract the 3D information from an arbitrary point. Instead it uses the block matching algorithms to obtain the disparity over the entire measuring range. This significantly slows down the 3D reconstruction process even though sometimes only a few points are relevant for the mesurements.

I am attaching a program that briefly explains the method behind stereo calculation for a single point. Two different calculations are shown: 1. using the Q matrix (perspective transformation matrix) to obtain the 3D coordinates and 2. using step-by-step calculation. In both cases, the results are the same.

Prior to any measurements system calibration needs to be performed, which is not covered by this post (see: https://decibel.ni.com/content/blogs/kl3m3n/2013/07/26/stereo-setup-parameters-calculation-and-labvi... and the stereo calibration in the NI Vision example folder). For the actual measurements after the calibration, I've used the same calibration board (see Figure 1 below) to extract all dots and calculated their 3D position.

3d_from_stereo_FP.png

Figure 1. Calibration board from the left and the right camera.

The 3D position of the dots is shown in Figure 2, along with the coordinates of the four points I've selected (the units are in mm).

3d.png

Figure 2. 3D reconstruction of grid pattern dots.

I've also calculated the Euclidean distance between the measured points and compared them with the actual distance on the calibration board. The distances between points Pt1, Pt2 and Pt3 differ for less than 1mm, while the difference between Pt1 and Pt4 is approximately 5mm. Mind that this is not the proper way to evaluate the measuring accuracy (for one thing, the board is flat), but gives some basic idea about the results (they are not way off, for example ).

The program attached is saved for Labview 2012. The code is messy, but I have no time to optimize it. If somebody finds it useful, I am certain that he/she will need to perform some modifications (for example, the method for the object detection on images from both cameras).

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Comments
Ivan0907
Member

Hi K,

For attached your code, can I know what is CX, CX', f and TX? And whether need to set this with my new graphs?

Thank you for confirming.calculation 3D point.jpg

Klemen
Active Participant

Hello,

did you check the block diagram? Everything you've asked is explained there.

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Ivan0907
Member

Hello K,

can i have one more question for "calculate3Dpoint"? I think you can check pic below, for the image in by put a image in a indicated folder, i'd like to know whether we can change to use "Vision Acquisition" instead; I changed this, but i facing issue in "IMAQ Get Rectified Image From Stereo", I was wondering at  what is "Left camera"? Because I cannot have more change for this.

in the 2nd, i got problem in "IMAQ Count Object 2".

can you help me check this? Thank you.how to change 3D cal.jpg

Klemen
Active Participant

Hello,

you need to configure two cameras (from different viewpoint) to be able to calculate 3D coordinates of an arbitrary point.

First you need to perform a stereo calibration and afterwards (the measurements), you need to be able to detect the same object on both images.

You need to acquire the image from the left and the right camera simultaneously and extract the image coordinates of the relevant object. In my case, the "IMAQ Count Object" is a really simple example.You can use this if you can assign a foreground status to the relevant object - for example, if you can threshlold the image and separate your object reliably. There are a lot of ways to extract the object, depending on your application...

Hope this helps.

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Ivan0907
Member

Hello K,

Thank you for the information.

I checked your code of "calculate3Dpoint" again, but I still don't know how you calculate and set those values, do you have any refererred paper or any more detail information can be support for me?

Thank you.

B.R

Ivan

Ivan0907
Member

Hello K,

One more question, do you have any detail infomration for Q matrix? I still have some problem in setting of Q matrix, thank you.

Klemen
Active Participant

Hello,

check this:

http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20repr...

and

http://zone.ni.com/reference/en-XX/help/372916P-01/nivisionconceptsdita/guid-acdaca59-cb7d-4c25-83ef...

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Ivan0907
Member

Hello K,

Thank you for the information.

In another side, whether any information for your method 2 (step by step)? i'm checking this also.

B.R