From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get 3D coordinates of reflective markers using two cameras?

Hi, 

 

I am using two Logitech Pro HD C920 Webcams to do the calibration. Calibration Quality is 2.2. It created a StereoCalibration.calib file, but can you please help me how can I extract  the intrensic and extrinsic parameters from that file. The technical specifications of the camera didnt specify focal legth so I was also wondering is there a way to calculate focal legth of the camera manually? 

 

Thank you

0 Kudos
Message 11 of 27
(3,966 Views)

@Anvitha wrote:

Hi, 

 

I am using two Logitech Pro HD C920 Webcams to do the calibration. Calibration Quality is 2.2. It created a StereoCalibration.calib file, but can you please help me how can I extract  the intrensic and extrinsic parameters from that file. The technical specifications of the camera didnt specify focal legth so I was also wondering is there a way to calculate focal legth of the camera manually? 

 

Thank you


Hello,

 

calibration quality cannot be 2.2, sice the value can only be somewhere between 0 and 1.

 

The focal lenght of the camera can be obtained form "IMAQ Get BInocular Stereo Calibration Info".

 

Please tell me what you have done so far and attach a calibration file and one pair of the images from both left and the right camera (with marker visible)...

 

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."
0 Kudos
Message 12 of 27
(3,958 Views)

Should I send you the pair of (RGB images or processed binary images) of the markers from both left and the right camera ?

0 Kudos
Message 13 of 27
(3,923 Views)

Can you tell me where is the focal length in binocular stereo calibration info? Is it in the fundamental matrix?

0 Kudos
Message 14 of 27
(3,919 Views)

Hi Klemen,

 

Sorry I think I told you the recification error number for calibration. I did the calibration again I got the Calibration Quality as 0.87 but, I also attached  the complete calibration info, the binocular stereo vision info and the stereo calib file. I think the baseline is 17.9cm from my info and can you please let me know where is the focal length in the matrix or is there a way to calculate the focal length and disparity using this info from Binocular stereo vision?

 

Thank you so much for your help.

0 Kudos
Message 15 of 27
(3,915 Views)

Hello,

 

could you attach two sample images also (they can be processed images). You can extract the parameters of your stereo setup form Q matrix. 

 

You can calculate the 3D coordinates using the Q matrix, which maps your image coordinates to the real-word coordinates. Taken from the Vision Concepts:

 

calc_3D.png

 

Don't forget to normalize the result with W!

 

What bothers me is your projection error - its high. Check out the quality of one calibration I performed below:

 

Calibration_FP.png

 

 

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."
0 Kudos
Message 16 of 27
(3,868 Views)

Hi Klemen,

 

Thank you for your help. I did the calibration again and I got the projection error as 1.57. I attached the processed Images with three markers. I tried to rectify the images to calculate the disparity by sending the stereo calibration file to the IMAQ read binocular stereo vision VI then to IMAQ get rectified binocular stereo vision and then I sent the binocluar stereo dump output to IMAQ get rectified binocular stereo image but it is giving an error that "There are too many stereo sessions open. You must close a session before you can open another one" I attached the pic of my VI. I have couple of questions:

 

1. Do I need to rectify the left and right images to calculate the disparity at a point(x,y) in left rectified image? If so is there a easiest way that I can rectify the   images and find the marker coordinates?

2. Is the x and y in 4*1 matrix from the left rectified image (right rectified image or non rectified image)? so that I can multiply to Q matrix

3. what is the scaling factor (mm/pix) of the result (real world coordinates)?

4. Can you also explain what each of the values represent in the matrices( Rotation Matrix, Translation Vector, Essential matrix, Fundamental matrix) that I got from the IMAQ get Binocular stereo calibration info VI

5. Is there a way to calculate disparity from the matrices info

 

Thank you so much.

Download All
0 Kudos
Message 17 of 27
(3,842 Views)

Hello,

 

you have not attached the new calibration file along with the images.

 

I do not know why it is giving you the error you've mentioned. Below is an example program to calculate the 3D coordinates:

 

test_BD.png

 

The values (with your old calibration) I got for the top-most marker are: (4.2, -19.7, 114.7) cm. Does that make any sense?

 

I hope the attached image answers most of your questions. Regarding scaling, I suppose you cannot just scale the pixels into real-world, unless the distance between the camera and the object is fixed at all times.

 

About the explanation of the matrices - please check the Labview Vision concepts manual, Labview help and search online...

 

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."
Message 18 of 27
(3,834 Views)

@Klemen wrote:

Hello,

 

you have not attached the new calibration file along with the images.

 

I do not know why it is giving you the error you've mentioned.

 


Actually, the error is due to your stereo session - you are closing the reference prior to the image rectification. It does not work this way...

This should be the final step. Also, use create stereo session prior to reading the file!

 

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."
0 Kudos
Message 19 of 27
(3,829 Views)

Hi Klemen,

 

Thank you so much for helping me to resolve my issue. You are awesome! This was really helpful I modified my VI and then I tried to calculate the X,Y,Z of the marker in realtime. When I used both left cameras as my reference coordinate system in IMAQ get rectified image it is a little close to the Z. but I got the z to be 226 so I checked whether it is accurate by measuring the distance from my left camera to the marker and I got 185 which is way off.

 

We moved the cameras today! so we tried to recalibrate the cameras for like 3hours since it gave us a lot of issues. It is detectng the circles in the calibration grid but after selecting the calibration data to be saved, the file is not saving and also it is not giving any Quality info from IMAQ learn binocular stereo calibration. Can you please help me with the calibration questions:

1. Should the cameras be placed at an angle or just parallel(striaght) to each other while doing the calibration?

2. Does the time of acquiring an image makes a difference?

3. The calibration works on luck. I mean it is saving the calib file with higher projection error sometimes or it doesnt work at all. We tried using 800 x 600 and also with more higher resolution for capturing the images for calibration.

4. Can you also explain the reason for the high projection error or what is this projection error?

 

Attached are the pair of images that I used for calibration and also the VI from your link. The first folder(New Pair 1) images gave me like 19... projection error and second folder(New Pair 2) gave me aroung 1.57 error but the third folder(New Pair 6) is not saving the calib file , not showing the quality info even it is detecting the circles on the grid. without correct calibration I think all my data will not be accurate. I would appreciate any help because after trying in different ways for a long time I have no idea why it doesn't work. Please let me know how to troubleshoot this issue .

 

Thank you!

 

 

0 Kudos
Message 20 of 27
(3,803 Views)