본문 바로가기

프로그래밍/OpenCV

[OPENCV] 스테레오 깊이맵 성능 높이기

OpenCV 를 이용한 스테레오 Depth Map 성능 개선

OpenCV 를 이용한 스테레오 Depth Map 생성 시, 결과물 품질을 높이는 일반적인 방법에 대해서 정리 한다.

이미지 캡처 환경에 대한 조언들

카메라 캘리브레이션

  • 카메라 intrinsic 과 stereo extrinsics 캘리브레이션을 최대한 정확히 하여 오차를 줄인다.

카메라 이미지 노이즈 최소화

  • 가능한 과다(소) 노출을 최대한 피하고, 적당한 대비(contrast)를 유지한다.
  • 반점(speckle) 을 줄이기 위해서는 ISO 를 낮춘다.
  • 가급적 JPEG 등의 압축을 사용하지 않는다. 압축된 이미지에서의 노이즈는 사람의 눈으로 보이지는 않지만, 머신비전 알고리즘에서는 발견될 수 있다.

OpenCV 스테레오 예제 이미지

OpenCV Stereo 파라미터의 이해

주요 파라미터

  • minDisparity 가능한 최소 차이의 값이다. 기본값은 0 이지만, 카메라와 가까운 물체에 집중하려면 양수의 값을 사용한다. 카메라와 먼, 무한대 거리의 물체를 포함시키려면 음수값을 적용할 수도 있다.
  • numDisparities 최대편차에서 최소편차를 뺀 값이다. 이미지의 피사계 심도로 이해할 수 있다. 상대적으로 얕은 피사계 심도 이미지는 작은 값을 사용하고, 깊은 피사계 심도 장면에는 큰 값을 사용한다. 16의 배수로 적용되어야 한다.
  • blockSize는 왼쪽과 오른쪽 이미지를 비교하는 블록의 크기(픽셀 단위)이다. 기본값은 3이다.

참고자료

https://docs.opencv.org/3.4/d2/d85/classcv_1_1StereoSGBM.html#adb7a50ef5f200ad9559e9b0e976cfa59

 

OpenCV: cv::StereoSGBM Class Reference

The class implements the modified H. Hirschmuller algorithm [103] that differs from the original one as follows: More... The class implements the modified H. Hirschmuller algorithm [103] that differs from the original one as follows: By default, the algori

docs.opencv.org

https://answers.opencv.org/question/213227/stereo-sgbm-algorithm/

 

Stereo SGBM Algorithm - OpenCV Q&A Forum

Hello everyone, I have been working on a project in which I need to compute a depth map. In order to do so, I have used both Stereo BM and Stereo SGBM algorithms after computing a stereo calibration. Both gave me not good results at all, even when playing

answers.opencv.org

https://answers.opencv.org/question/182049/pythonstereo-disparity-quality-problems/

 

[Python]Stereo disparity quality problems - OpenCV Q&A Forum

[Python]Stereo disparity quality problems edit Disclaimer: i am a beginner. I edited the example python stereo_match.py code a bit to get "live" feed from my 2 webcams. I calibrated them about right, the Y offset is right but i have not set the distortion

answers.opencv.org