Ask Your Question
0

Rectified Images Show unwanted results, OpenCV with Stereo Vision

asked 2020-08-03 04:24:05 -0600

sonnguyen9800 gravatar image

I am having trouble when trying to create depth map using OpenCV on Python. The problem is that the rectified images appears to be wrapped, or distorted. Here is the code.

https://pastebin.com/embed_js/1DHpCPgv

Long story short, the code performs a series of program begin with:

Reading image file captured from two cameras Calibrate each cameras separately Using instrict matrices and distortion values to be parameters when i call StereoCalibrate() The images folders I used contains 68 different images for each camera (136 in total). The results from calibrateCamera() are 0.77 and 0.94 for each cameras.

The retVal I collected from StereoCalibrate() was huge, 39.0. So I guessed there is problem in the codes.

The images of camera frame captured before and after rectification are shown here: original image rectified image Original Rectified Image

Now, I truly frustrated as I don't know what I have done wrong? I also tried to search this problem in Google but it's seem that the solution is to calibrate cameras more to get better instrict matrices and distortions values. Personally, I don't believe this is the core issues and think that I did choose wrong parameters for method instead. What do you think? Please gives me some advices ... ~

edit retag flag offensive close merge delete

Comments

Thank you so much!

My images collections are something like this: https://imgur.com/a/258ldCr and https://imgur.com/a/KLQJaYU.

What do you think? I have around 600 pics (300 for each camera). I think the more images I have, the better the result be. But the processing time is so slow.

How many images you think is enough?

sonnguyen9800 gravatar imagesonnguyen9800 ( 2020-08-03 06:59:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-08-03 05:44:39 -0600

berak gravatar image

updated 2020-08-03 07:45:48 -0600

The retVal I collected from StereoCalibrate() was huge, 39.0

indeed far too large (<1 would be ok). but the problem are usually the chessboard images, not the code. having 68 pairs is already quite a lot (can you show a few ?), so have a look at those, and throw out any where

  • not all corners are visible or occluded
  • specular highlights (white glares)

please also make sure,

  • you have enough images from the corners of the frame, as most distortion happens there
  • enough variation in pose (all 3 axes) and distance
  • your chessboard is absolutely flat (no cheating here !!)
  • chessboard is rectangular, not quadratic
  • sufficiently large white border (quiet zone) in your printed chessboard (at least 1 square)
edit flag offensive delete link more

Comments

1

Thank you so much!

My images collections are something like this: https://imgur.com/a/258ldCr and https://imgur.com/a/KLQJaYU.

What do you think? I have around 600 pics (300 for each camera). I think the more images I have, the better the result be. But the processing time is so slow.

How many images you think is enough?

sonnguyen9800 gravatar imagesonnguyen9800 ( 2020-08-03 07:00:32 -0600 )edit

How many images you think is enough ? 20-30 pairs should be enough

thanks for the images, as i thought -- they're all shite.

in both images some corners are occluded, and the clip covers the print. - unusable

also, not enough white border, and you did not get no cheating , hehe ;)

maybe go to some pro printing shop and have them print it on some wooden or metal plate, at least take more effort of producing an absolutely flat board

you also need more distance to the camera

berak gravatar imageberak ( 2020-08-03 07:27:05 -0600 )edit
1

Oh crap :3 Thanks you so much. Have a good day plz :3

sonnguyen9800 gravatar imagesonnguyen9800 ( 2020-08-03 08:41:01 -0600 )edit

yea, gl. mentally prepare for that this will need several attempts to get a good result.

and NEVER touch the focus again, else you have to recalibrate

berak gravatar imageberak ( 2020-08-03 08:44:16 -0600 )edit

Well, although I don' have new board yet, I did try to re-calibrate the cameras, this time I put the paper on the ground to make it flat and remove the blue clip used previously from the frame. This time the retValue (re-projection value) returned from calibrateCamera() is 0.24 - 0.26, much lesser than before (0.97 and 0.78). However, this time, the returned value from StereoCalibrate is 55.47 ???

A little bit confused. I thought the lesser the re-projection value from calibrateCamera() is, the better result came from StereoCalibrate must be?

sonnguyen9800 gravatar imagesonnguyen9800 ( 2020-08-03 10:59:58 -0600 )edit

returned value from StereoCalibrate is 55.47

this is unfortunately the only relevant one.you also do not really need a single-cam calibration before here..

and no, "paper lying on the ground" is NOT FLAT ENOUGH. you have to laminate it to something, print it on sticky foil, get creative !

next round ;(

berak gravatar imageberak ( 2020-08-03 11:05:12 -0600 )edit

Hello from the other side :v

Well, this time the reprojection value from StereoCalibrate is 0.73. The image look better, like this:

image

As you can see, both images are not horizontally aligned together. A little bit weird. Based on your experience, what are your ideas about this? Also, is 0.73 a good result?

Btw, a flatter chess plane truly indicates much more better result! :3

sonnguyen9800 gravatar imagesonnguyen9800 ( 2020-08-04 00:01:06 -0600 )edit

Your first image is zoom in and the second image is zoom out.. This may not help.

supra56 gravatar imagesupra56 ( 2020-08-05 22:20:36 -0600 )edit

Can you talk a little bit more @supra56? My camera is USB type and me personally don't think it can zoom in/out the images. Still researching about the topic!

sonnguyen9800 gravatar imagesonnguyen9800 ( 2020-08-06 09:18:41 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-08-03 04:24:05 -0600

Seen: 2,393 times

Last updated: Aug 03 '20