Depth map shows everything grey! OpenCV- Python [closed]
Hello! My code:
import cv2
import numpy as np
imgL = cv2.imread('Blender_Suzanne1.jpg')
img1 = cv2.cvtColor(imgL, cv2.COLOR_BGR2GRAY)
imgR = cv2.imread('Blender_Suzanne2.jpg')
img2 = cv2.cvtColor(imgR, cv2.COLOR_BGR2GRAY)
stereo = cv2.StereoBM_create(numDisparities = 16, blockSize = 17)
disparity = stereo.compute(img2, img1)
cv2.imshow('DepthMap', disparity)
cv2.waitKey()
cv2.destroyAllWindows()
When I run it, I see a window which is all grey? I think it is wrong. I used this code from the OpenCV docs website. Can anyone help?
depth maps are CV_16U [0..0xffff]. you probably have to filter it a bit, like subtract some offset, scale it, convert to CV_8U to see the disparity properly
But this is converted to Gray form. i.e. CV_8U right? or How do you propose changes?
the input, yes, but you're looking at the disparity image, which needs some treatment.
stereo_match.cpp (from the samples) has a line like:
also note, that the python tuts/samples use matplotlib for displaying, which might handle things differently
Thanks. I posted the docs code as it is i.e. with matplotlib and it finally showed something. I guess that must have something to do with the correct from to display.