Image Processing: Bad Quality of Disparity Image with OpenCV

巧了我就是萌 提交于 2019-12-04 15:18:37

Most stereo algorithms require the input images to be rectified. Rectification transforms images so that corresponding epipolar lines are corresponding horizontal lines in both images. For rectification, you need to know both intrinsic and extrinsic parameters of your cameras.

OpenCV has all the tools required to perform both calibration and rectification. If you need to perform calibration, you need to have a calibration pattern (chessboard) available as well.

In short:

  1. Compute intrinsic camera parameters using calibrateCamera().
  2. Use the intrinsic parameters with stereoCalibrate() to perform extrinsic calibration of the stereo pair.
  3. Using the paramters from stereoCalibrate(), compute rectification parameters with stereoRectify()
  4. Using rectification parameters, calculate maps used for rectification and undistortion with initUndistortRectifyMap()

Now your cameras are calibrated and you can perform rectification and undistortion using remap() for images taken with the camera pair (as long as the cameras do not move relatively to each other). The rectified images calculated by remap() can now be used to calculate disparity images.

Additionally, I recommend checking out some relevant text book on the topic. Learning OpenCV: Computer Vision with the OpenCV Library has a very practical description of the process.

I agree with @Catree's comment and @sebasth's answer, mainly because your images are not rectified at all.

However, another issue may occur and I would like to warn you about this. I tried to leave a comment on @sebasth's answer, but I can't comment yet...

As you said you are using low resolution usb cameras, it makes me believe these cameras have the light exposure made by Rolling Shutter lenses. For scenes in movement and in constant change, the ideal are Global Shutter cameras. This is especially relevant if you intend to use this for scenes in movement.

(Example of Rolling Shutter effect: enter link description here).

So with the Rolling Shutter lenses you will also have to be careful about cameras synchronization.

It can work with Rolling shutter cameras, but you will need to take care with lens synchronization, preferably in a controlled environment (even with little change in lighting).

Also remember to turn off the automatic camera parameters, like: "White Balance" and especially the "Exposure".

Best regards!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!