Error for Disparity Map Code: cv::StereoSGBMImpl::compute' (-215 OpenCV)









up vote
0
down vote

favorite












I am trying to create a high quality disparity map. However, my current disparity map's output is quite terrible. Here is my code for my current iteration:



from __future__ import print_function
import os
import numpy as np
import cv2 as cv
import time

ply_header = '''ply
format ascii 1.0
element vertex %(vert_num)d
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
'''

cap = cv.VideoCapture(0)
cap2 = cv.VideoCapture(2)
cap.set(3,640) # set Width
cap.set(4,480) # set Height
cap2.set(3,640) # set Width
cap2.set(4,480) # set Height

def write_ply(fn, verts, colors):
verts = verts.reshape(-1, 3)
colors = colors.reshape(-1, 3)
verts = np.hstack([verts, colors])
with open(fn, 'wb') as f:
f.write((ply_header % dict(vert_num=len(verts))).encode('utf-8'))
np.savetxt(f, verts, fmt='%f %f %f %d %d %d ')

while(True):
if __name__ == '__main__':
print('loading images...')
bool1, image1 = cap.read()
bool2, image2 = cap2.read()
cv.imwrite('opencvL'+'.jpg', image1)
cv.imwrite('opencvR'+'.jpg', image2)
imgL = cv.imread('opencvL.jpg') # downscale images for faster processing
imgR = cv.imread('opencvR.jpg')

# disparity range is tuned for 'aloe' image pair
window_size = 7
min_disp = 0
max_disp = 160
num_disp = 112-min_disp
stereo = cv.StereoSGBM_create(minDisparity = min_disp,
numDisparities = num_disp,
blockSize = 5,
P1 = 8*3*window_size**2,
P2 = 32*3*window_size**2,
disp12MaxDiff = 1,
uniquenessRatio = 15,
speckleWindowSize = 50,
speckleRange = 2
)

print('computing disparity...')
disp = stereo.compute(imgL, imgR).astype(np.float32) / 16.0

print('generating 3d point cloud...',)
h, w = imgL.shape[:2]
f = 0.8*w # guess for focal length
Q = np.float32([[1, 0, 0, -0.5*w],
[0,-1, 0, 0.5*h], # turn points 180 deg around x-axis,
[0, 0, 0, -f], # so that y-axis looks up
[0, 0, 1, 0]])
points = cv.reprojectImageTo3D(disp, Q)
colors = cv.cvtColor(imgL, cv.COLOR_BGR2RGB)
mask = disp > disp.min()
out_points = points[mask]
out_colors = colors[mask]
#out_fn = 'out.ply'
#write_ply('out.ply', out_points, out_colors)
#print('%s saved' % 'out.ply')
cv.imshow('left', imgL)
cv.imshow('right', imgR)
cv.imshow('disparity', (disp-min_disp)/num_disp)
os.remove("opencvL.jpg")
#os.remove("out.ply")
os.remove("opencvR.jpg")

if cv.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(.1)
else:
break
# When everything done, release the capture
cap.release()
cv.destroyAllWindows()


This code works, but the output is horrible. It does not even resemble a disparity map. This is what I am getting:



Image of output



Hence, I tried another code that I found online with some edits. Here it is:



import numpy as np
from sklearn.preprocessing import normalize
import cv2

print('loading images...')
imgL = cv2.imread('left.jpg') # downscale images for faster processing
imgR = cv2.imread('right.jpg')

# SGBM Parameters -----------------
window_size = 3 # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely

left_matcher = cv2.StereoSGBM_create(
minDisparity=0,
numDisparities=160, # max_disp has to be dividable by 16 f. E. HH 192, 256
blockSize=5,
P1=8 * 3 * window_size ** 2, # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely
P2=32 * 3 * window_size ** 2,
disp12MaxDiff=1,
uniquenessRatio=15,
speckleWindowSize=0,
speckleRange=2,
preFilterCap=63,
mode=cv2.STEREO_SGBM_MODE_SGBM_3WAY
)

right_matcher = cv2.ximgproc.createRightMatcher(left_matcher)

# FILTER Parameters
lmbda = 80000
sigma = 1.2
visual_multiplier = 1.0

wls_filter = cv2.ximgproc.createDisparityWLSFilter(matcher_left=left_matcher)
wls_filter.setLambda(lmbda)
wls_filter.setSigmaColor(sigma)

print('computing disparity...')
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
dispr = right_matcher.compute(imgR, imgL) # .astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg = wls_filter.filter(displ, imgL, None, dispr) # important to put "imgL" here!!!

filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
cv2.imshow('Disparity Map', filteredImg)
cv2.waitKey()
cv2.destroyAllWindows()


However, when I try to run this, this is my output from the command terminal:



 C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>python onlinefiltereddisparitymap.py
C:UsersAdithya KumarAppDataLocalProgramsPythonPython36-32libsite-packagessklearnexternalsjoblibexternalscloudpicklecloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
loading images...
computing disparity...
Traceback (most recent call last):
File "onlinefiltereddisparitymap.py", line 38, in <module>
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescalib3dsrcstereosgbm.cpp:2156: error: (-215:Assertion failed) left.size() == right.size() && left.type() == right.type() && left.depth() == CV_8U in function 'cv::StereoSGBMImpl::compute'


C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>


Any help would be much appreciated.










share|improve this question





















  • That error message is quite clear -- either the two inputs aren't the same shape, type, or they're not holding 8bit unsigned integers. So, inspect the inputs are make sure they satisfy the requirements.
    – Dan Mašek
    Nov 9 at 17:13














up vote
0
down vote

favorite












I am trying to create a high quality disparity map. However, my current disparity map's output is quite terrible. Here is my code for my current iteration:



from __future__ import print_function
import os
import numpy as np
import cv2 as cv
import time

ply_header = '''ply
format ascii 1.0
element vertex %(vert_num)d
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
'''

cap = cv.VideoCapture(0)
cap2 = cv.VideoCapture(2)
cap.set(3,640) # set Width
cap.set(4,480) # set Height
cap2.set(3,640) # set Width
cap2.set(4,480) # set Height

def write_ply(fn, verts, colors):
verts = verts.reshape(-1, 3)
colors = colors.reshape(-1, 3)
verts = np.hstack([verts, colors])
with open(fn, 'wb') as f:
f.write((ply_header % dict(vert_num=len(verts))).encode('utf-8'))
np.savetxt(f, verts, fmt='%f %f %f %d %d %d ')

while(True):
if __name__ == '__main__':
print('loading images...')
bool1, image1 = cap.read()
bool2, image2 = cap2.read()
cv.imwrite('opencvL'+'.jpg', image1)
cv.imwrite('opencvR'+'.jpg', image2)
imgL = cv.imread('opencvL.jpg') # downscale images for faster processing
imgR = cv.imread('opencvR.jpg')

# disparity range is tuned for 'aloe' image pair
window_size = 7
min_disp = 0
max_disp = 160
num_disp = 112-min_disp
stereo = cv.StereoSGBM_create(minDisparity = min_disp,
numDisparities = num_disp,
blockSize = 5,
P1 = 8*3*window_size**2,
P2 = 32*3*window_size**2,
disp12MaxDiff = 1,
uniquenessRatio = 15,
speckleWindowSize = 50,
speckleRange = 2
)

print('computing disparity...')
disp = stereo.compute(imgL, imgR).astype(np.float32) / 16.0

print('generating 3d point cloud...',)
h, w = imgL.shape[:2]
f = 0.8*w # guess for focal length
Q = np.float32([[1, 0, 0, -0.5*w],
[0,-1, 0, 0.5*h], # turn points 180 deg around x-axis,
[0, 0, 0, -f], # so that y-axis looks up
[0, 0, 1, 0]])
points = cv.reprojectImageTo3D(disp, Q)
colors = cv.cvtColor(imgL, cv.COLOR_BGR2RGB)
mask = disp > disp.min()
out_points = points[mask]
out_colors = colors[mask]
#out_fn = 'out.ply'
#write_ply('out.ply', out_points, out_colors)
#print('%s saved' % 'out.ply')
cv.imshow('left', imgL)
cv.imshow('right', imgR)
cv.imshow('disparity', (disp-min_disp)/num_disp)
os.remove("opencvL.jpg")
#os.remove("out.ply")
os.remove("opencvR.jpg")

if cv.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(.1)
else:
break
# When everything done, release the capture
cap.release()
cv.destroyAllWindows()


This code works, but the output is horrible. It does not even resemble a disparity map. This is what I am getting:



Image of output



Hence, I tried another code that I found online with some edits. Here it is:



import numpy as np
from sklearn.preprocessing import normalize
import cv2

print('loading images...')
imgL = cv2.imread('left.jpg') # downscale images for faster processing
imgR = cv2.imread('right.jpg')

# SGBM Parameters -----------------
window_size = 3 # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely

left_matcher = cv2.StereoSGBM_create(
minDisparity=0,
numDisparities=160, # max_disp has to be dividable by 16 f. E. HH 192, 256
blockSize=5,
P1=8 * 3 * window_size ** 2, # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely
P2=32 * 3 * window_size ** 2,
disp12MaxDiff=1,
uniquenessRatio=15,
speckleWindowSize=0,
speckleRange=2,
preFilterCap=63,
mode=cv2.STEREO_SGBM_MODE_SGBM_3WAY
)

right_matcher = cv2.ximgproc.createRightMatcher(left_matcher)

# FILTER Parameters
lmbda = 80000
sigma = 1.2
visual_multiplier = 1.0

wls_filter = cv2.ximgproc.createDisparityWLSFilter(matcher_left=left_matcher)
wls_filter.setLambda(lmbda)
wls_filter.setSigmaColor(sigma)

print('computing disparity...')
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
dispr = right_matcher.compute(imgR, imgL) # .astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg = wls_filter.filter(displ, imgL, None, dispr) # important to put "imgL" here!!!

filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
cv2.imshow('Disparity Map', filteredImg)
cv2.waitKey()
cv2.destroyAllWindows()


However, when I try to run this, this is my output from the command terminal:



 C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>python onlinefiltereddisparitymap.py
C:UsersAdithya KumarAppDataLocalProgramsPythonPython36-32libsite-packagessklearnexternalsjoblibexternalscloudpicklecloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
loading images...
computing disparity...
Traceback (most recent call last):
File "onlinefiltereddisparitymap.py", line 38, in <module>
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescalib3dsrcstereosgbm.cpp:2156: error: (-215:Assertion failed) left.size() == right.size() && left.type() == right.type() && left.depth() == CV_8U in function 'cv::StereoSGBMImpl::compute'


C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>


Any help would be much appreciated.










share|improve this question





















  • That error message is quite clear -- either the two inputs aren't the same shape, type, or they're not holding 8bit unsigned integers. So, inspect the inputs are make sure they satisfy the requirements.
    – Dan Mašek
    Nov 9 at 17:13












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to create a high quality disparity map. However, my current disparity map's output is quite terrible. Here is my code for my current iteration:



from __future__ import print_function
import os
import numpy as np
import cv2 as cv
import time

ply_header = '''ply
format ascii 1.0
element vertex %(vert_num)d
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
'''

cap = cv.VideoCapture(0)
cap2 = cv.VideoCapture(2)
cap.set(3,640) # set Width
cap.set(4,480) # set Height
cap2.set(3,640) # set Width
cap2.set(4,480) # set Height

def write_ply(fn, verts, colors):
verts = verts.reshape(-1, 3)
colors = colors.reshape(-1, 3)
verts = np.hstack([verts, colors])
with open(fn, 'wb') as f:
f.write((ply_header % dict(vert_num=len(verts))).encode('utf-8'))
np.savetxt(f, verts, fmt='%f %f %f %d %d %d ')

while(True):
if __name__ == '__main__':
print('loading images...')
bool1, image1 = cap.read()
bool2, image2 = cap2.read()
cv.imwrite('opencvL'+'.jpg', image1)
cv.imwrite('opencvR'+'.jpg', image2)
imgL = cv.imread('opencvL.jpg') # downscale images for faster processing
imgR = cv.imread('opencvR.jpg')

# disparity range is tuned for 'aloe' image pair
window_size = 7
min_disp = 0
max_disp = 160
num_disp = 112-min_disp
stereo = cv.StereoSGBM_create(minDisparity = min_disp,
numDisparities = num_disp,
blockSize = 5,
P1 = 8*3*window_size**2,
P2 = 32*3*window_size**2,
disp12MaxDiff = 1,
uniquenessRatio = 15,
speckleWindowSize = 50,
speckleRange = 2
)

print('computing disparity...')
disp = stereo.compute(imgL, imgR).astype(np.float32) / 16.0

print('generating 3d point cloud...',)
h, w = imgL.shape[:2]
f = 0.8*w # guess for focal length
Q = np.float32([[1, 0, 0, -0.5*w],
[0,-1, 0, 0.5*h], # turn points 180 deg around x-axis,
[0, 0, 0, -f], # so that y-axis looks up
[0, 0, 1, 0]])
points = cv.reprojectImageTo3D(disp, Q)
colors = cv.cvtColor(imgL, cv.COLOR_BGR2RGB)
mask = disp > disp.min()
out_points = points[mask]
out_colors = colors[mask]
#out_fn = 'out.ply'
#write_ply('out.ply', out_points, out_colors)
#print('%s saved' % 'out.ply')
cv.imshow('left', imgL)
cv.imshow('right', imgR)
cv.imshow('disparity', (disp-min_disp)/num_disp)
os.remove("opencvL.jpg")
#os.remove("out.ply")
os.remove("opencvR.jpg")

if cv.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(.1)
else:
break
# When everything done, release the capture
cap.release()
cv.destroyAllWindows()


This code works, but the output is horrible. It does not even resemble a disparity map. This is what I am getting:



Image of output



Hence, I tried another code that I found online with some edits. Here it is:



import numpy as np
from sklearn.preprocessing import normalize
import cv2

print('loading images...')
imgL = cv2.imread('left.jpg') # downscale images for faster processing
imgR = cv2.imread('right.jpg')

# SGBM Parameters -----------------
window_size = 3 # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely

left_matcher = cv2.StereoSGBM_create(
minDisparity=0,
numDisparities=160, # max_disp has to be dividable by 16 f. E. HH 192, 256
blockSize=5,
P1=8 * 3 * window_size ** 2, # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely
P2=32 * 3 * window_size ** 2,
disp12MaxDiff=1,
uniquenessRatio=15,
speckleWindowSize=0,
speckleRange=2,
preFilterCap=63,
mode=cv2.STEREO_SGBM_MODE_SGBM_3WAY
)

right_matcher = cv2.ximgproc.createRightMatcher(left_matcher)

# FILTER Parameters
lmbda = 80000
sigma = 1.2
visual_multiplier = 1.0

wls_filter = cv2.ximgproc.createDisparityWLSFilter(matcher_left=left_matcher)
wls_filter.setLambda(lmbda)
wls_filter.setSigmaColor(sigma)

print('computing disparity...')
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
dispr = right_matcher.compute(imgR, imgL) # .astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg = wls_filter.filter(displ, imgL, None, dispr) # important to put "imgL" here!!!

filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
cv2.imshow('Disparity Map', filteredImg)
cv2.waitKey()
cv2.destroyAllWindows()


However, when I try to run this, this is my output from the command terminal:



 C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>python onlinefiltereddisparitymap.py
C:UsersAdithya KumarAppDataLocalProgramsPythonPython36-32libsite-packagessklearnexternalsjoblibexternalscloudpicklecloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
loading images...
computing disparity...
Traceback (most recent call last):
File "onlinefiltereddisparitymap.py", line 38, in <module>
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescalib3dsrcstereosgbm.cpp:2156: error: (-215:Assertion failed) left.size() == right.size() && left.type() == right.type() && left.depth() == CV_8U in function 'cv::StereoSGBMImpl::compute'


C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>


Any help would be much appreciated.










share|improve this question













I am trying to create a high quality disparity map. However, my current disparity map's output is quite terrible. Here is my code for my current iteration:



from __future__ import print_function
import os
import numpy as np
import cv2 as cv
import time

ply_header = '''ply
format ascii 1.0
element vertex %(vert_num)d
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
'''

cap = cv.VideoCapture(0)
cap2 = cv.VideoCapture(2)
cap.set(3,640) # set Width
cap.set(4,480) # set Height
cap2.set(3,640) # set Width
cap2.set(4,480) # set Height

def write_ply(fn, verts, colors):
verts = verts.reshape(-1, 3)
colors = colors.reshape(-1, 3)
verts = np.hstack([verts, colors])
with open(fn, 'wb') as f:
f.write((ply_header % dict(vert_num=len(verts))).encode('utf-8'))
np.savetxt(f, verts, fmt='%f %f %f %d %d %d ')

while(True):
if __name__ == '__main__':
print('loading images...')
bool1, image1 = cap.read()
bool2, image2 = cap2.read()
cv.imwrite('opencvL'+'.jpg', image1)
cv.imwrite('opencvR'+'.jpg', image2)
imgL = cv.imread('opencvL.jpg') # downscale images for faster processing
imgR = cv.imread('opencvR.jpg')

# disparity range is tuned for 'aloe' image pair
window_size = 7
min_disp = 0
max_disp = 160
num_disp = 112-min_disp
stereo = cv.StereoSGBM_create(minDisparity = min_disp,
numDisparities = num_disp,
blockSize = 5,
P1 = 8*3*window_size**2,
P2 = 32*3*window_size**2,
disp12MaxDiff = 1,
uniquenessRatio = 15,
speckleWindowSize = 50,
speckleRange = 2
)

print('computing disparity...')
disp = stereo.compute(imgL, imgR).astype(np.float32) / 16.0

print('generating 3d point cloud...',)
h, w = imgL.shape[:2]
f = 0.8*w # guess for focal length
Q = np.float32([[1, 0, 0, -0.5*w],
[0,-1, 0, 0.5*h], # turn points 180 deg around x-axis,
[0, 0, 0, -f], # so that y-axis looks up
[0, 0, 1, 0]])
points = cv.reprojectImageTo3D(disp, Q)
colors = cv.cvtColor(imgL, cv.COLOR_BGR2RGB)
mask = disp > disp.min()
out_points = points[mask]
out_colors = colors[mask]
#out_fn = 'out.ply'
#write_ply('out.ply', out_points, out_colors)
#print('%s saved' % 'out.ply')
cv.imshow('left', imgL)
cv.imshow('right', imgR)
cv.imshow('disparity', (disp-min_disp)/num_disp)
os.remove("opencvL.jpg")
#os.remove("out.ply")
os.remove("opencvR.jpg")

if cv.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(.1)
else:
break
# When everything done, release the capture
cap.release()
cv.destroyAllWindows()


This code works, but the output is horrible. It does not even resemble a disparity map. This is what I am getting:



Image of output



Hence, I tried another code that I found online with some edits. Here it is:



import numpy as np
from sklearn.preprocessing import normalize
import cv2

print('loading images...')
imgL = cv2.imread('left.jpg') # downscale images for faster processing
imgR = cv2.imread('right.jpg')

# SGBM Parameters -----------------
window_size = 3 # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely

left_matcher = cv2.StereoSGBM_create(
minDisparity=0,
numDisparities=160, # max_disp has to be dividable by 16 f. E. HH 192, 256
blockSize=5,
P1=8 * 3 * window_size ** 2, # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely
P2=32 * 3 * window_size ** 2,
disp12MaxDiff=1,
uniquenessRatio=15,
speckleWindowSize=0,
speckleRange=2,
preFilterCap=63,
mode=cv2.STEREO_SGBM_MODE_SGBM_3WAY
)

right_matcher = cv2.ximgproc.createRightMatcher(left_matcher)

# FILTER Parameters
lmbda = 80000
sigma = 1.2
visual_multiplier = 1.0

wls_filter = cv2.ximgproc.createDisparityWLSFilter(matcher_left=left_matcher)
wls_filter.setLambda(lmbda)
wls_filter.setSigmaColor(sigma)

print('computing disparity...')
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
dispr = right_matcher.compute(imgR, imgL) # .astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg = wls_filter.filter(displ, imgL, None, dispr) # important to put "imgL" here!!!

filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
cv2.imshow('Disparity Map', filteredImg)
cv2.waitKey()
cv2.destroyAllWindows()


However, when I try to run this, this is my output from the command terminal:



 C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>python onlinefiltereddisparitymap.py
C:UsersAdithya KumarAppDataLocalProgramsPythonPython36-32libsite-packagessklearnexternalsjoblibexternalscloudpicklecloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
loading images...
computing disparity...
Traceback (most recent call last):
File "onlinefiltereddisparitymap.py", line 38, in <module>
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
cv2.error: OpenCV(3.4.3) C:projectsopencv-pythonopencvmodulescalib3dsrcstereosgbm.cpp:2156: error: (-215:Assertion failed) left.size() == right.size() && left.type() == right.type() && left.depth() == CV_8U in function 'cv::StereoSGBMImpl::compute'


C:UsersAdithya KumarDesktopsciencefair18githubSciencefair2018-19>


Any help would be much appreciated.







opencv






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 17:02









Adithya Shakthi Kumar

87




87











  • That error message is quite clear -- either the two inputs aren't the same shape, type, or they're not holding 8bit unsigned integers. So, inspect the inputs are make sure they satisfy the requirements.
    – Dan Mašek
    Nov 9 at 17:13
















  • That error message is quite clear -- either the two inputs aren't the same shape, type, or they're not holding 8bit unsigned integers. So, inspect the inputs are make sure they satisfy the requirements.
    – Dan Mašek
    Nov 9 at 17:13















That error message is quite clear -- either the two inputs aren't the same shape, type, or they're not holding 8bit unsigned integers. So, inspect the inputs are make sure they satisfy the requirements.
– Dan Mašek
Nov 9 at 17:13




That error message is quite clear -- either the two inputs aren't the same shape, type, or they're not holding 8bit unsigned integers. So, inspect the inputs are make sure they satisfy the requirements.
– Dan Mašek
Nov 9 at 17:13

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230263%2ferror-for-disparity-map-code-cvstereosgbmimplcompute-215-opencv%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230263%2ferror-for-disparity-map-code-cvstereosgbmimplcompute-215-opencv%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus