首页 > 解决方案 > OpenCV:为深度图调整视频帧大小时出错

问题描述

我正在使用 opencv3.4 执行深度图。当我获得校准文件时,我想拥有视差图真正的 2 立体相机。为了做到这一点,我调用了校准文件,但是当我尝试调整视频窗口大小并重新映射视频窗口时,出现以下错误。注意:相同的脚本适用于仅取自 8 幅图像的校准文件。当前文件来自 21 张图像。可能是什么问题呢?

错误

当我尝试运行部门地图时,这里显示的所有内容

  File "<ipython-input-5-f2eac343bb87>", line 1, in <module>
    runfile('C:/Users/gaetano/Desktop/SONIDO ORIGINAL/biggerDepth2.py', wdir='C:/Users/gaetano/Desktop/SONIDO ORIGINAL')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/gaetano/Desktop/SONIDO ORIGINAL/biggerDepth2.py", line 68, in <module>
    dst= cv2.resize(dst, (0,0),dst, 2.0, 2.0, cv2.INTER_LINEAR)

error: C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:4044: error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize

代码

这段代码末尾的 line resize 中的代码中断,所以 remap 应该没问题。是我给出的值x的问题y,,,,?或者可能是关于矩阵位数的问题?wh

ret, frame = cap1.read()
ret, frame2 = cap2.read()

#cv2.imshow('frame', frame)
#cv2.imshow('frame2', frame2)
#imgL = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
#imgR = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
##    dst = cv2.remap(frame, mapx1, mapy1, 
cv2.INTER_LINEAR,cv2.BORDER_CONSTANT, 0)

# imgL_rectified = cv2.remap(imgL, camera_config.left_map1, 
camera_config.left_map2, cv2.INTER_LINEAR)
dst = cv2.remap(frame, mapx1, mapy1, cv2.INTER_LINEAR)

dst = dst[y:y + h, x:x + w]
#print(dst)
##       dst2 = cv2.remap(frame2, mapx2, mapy2, 
cv2.INTER_LINEAR,cv2.BORDER_CONSTANT, 0)
dst2 = cv2.remap (frame2, mapx2, mapy2, cv2.INTER_LINEAR)
dst2 = dst2[y:y + h, x:x + w]

dst= cv2.resize(dst, (0,0),dst, 2.0, 2.0, cv2.INTER_LINEAR)
dst2 = cv2.resize(dst2, (0,0),dst2, 2.0, 2.0,cv2.INTER_LINEAR)

标签: pythonresizeopencv3.0remap

解决方案


看看下面的链接,断言失败:size.width>0 && size.height>0 in function imshow

另外,检查 in 返回的retret, frame = cap1.read()。我认为这可能是错误的,根本没有读取图像。


推荐阅读