what parameter adjust can make the disparity result correctly? using cv2.StereoBM in opencv

Viewed 1001

result left right

   import numpy as np
   import cv2

   imgL = cv2.imread("C:/Users/admin/jupyter/car/challenge_pictrue/right/right2.jpg ",0)
   imgR = cv2.imread("C:/Users/admin/jupyter/car/challenge_pictrue/left/left2.jpg ",0)

   cv2.imshow('imgL', imgL)
   cv2.imshow('imgR', imgR)

   stereo = cv2.StereoBM_create(numDisparities=16, blockSize=17)
   disparity = stereo.compute(imgL, imgR)
   disparity = cv2.normalize(disparity, disparity, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, 
   dtype=cv2.CV_8U)
   cv2.imshow('disparity', disparity)
   cv2.waitKey(0)
   cv2.destroyAllWindows()

"What's parameter should i adjust can make the result correctly?"

1 Answers

Wrong method. BM is only meant for simple indoor use with low dynamic measuring range. With indoor image, you just need a adjsut mindisp and number of disp and window size.

For outdoor, it is more complex. Maybe u just start. BM and other global based method has the poor result. Either disfigured for overfitting, or streaking effect due to local similarity error.

Current state of the art for traditional CV is the SGM based method proposed by HH. And for the deep learning-based method, there is no best case, vary from case to case/dataset to dataset. The work from lecun Žbontar "Stereo Matching by Training a Convolutional Neural Network " is sth that I used for comparison often.

enter image description here

Try not to use too cheap/low complexity algorithms for advanced tasks. And also if you use it for actual driving action control( because I saw you other Vdispary problem), you will get yourself killed. I've tested this in various locations. It not the right way. Grab a LIDAR or other active ranging for extra safety

This is mine results using census with SGM. you can refer to this link https://docs.opencv.org/trunk/d3/d14/tutorial_ximgproc_disparity_filtering.html for reproducing.

enter image description here

The white dots denotes the close object. by Vdispaity, it will say there is close by object when there are none. Thus it will cause car to suddenly stop. You can refer to my thesis at NTU for how to remove them. And remember to cite them properly

enter image description here

Regards

Dr Yuan Shenghai

Related