1

I am performing a depth map with opencv3.4. As I obtained the calibration file, I would like to have the disparity map true 2 stereo cameras. In order to do this i call the calibration file but when i try to resize and remap the video windows, i got the following error. Note: the same script, works with a calibration file taken from just 8 images. the current file is from 21 images. what could be the problem?

Error

here everything it display when i try to run the dept map

  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

Code

The code interrupt in line resize in the end of this code, so the remap should be ok. Is a problem of the value I give x, y , w, h? or maybe a problem about the number of bit of the matrix?

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)
akshat
  • 1,219
  • 1
  • 8
  • 24
gaetano ma
  • 139
  • 12

1 Answers1

0

Have a look at the following link, Assertion failure : size.width>0 && size.height>0 in function imshow

Also, check the value returned by ret in ret, frame = cap1.read(). I think it may be false and there is no image read at all.

akshat
  • 1,219
  • 1
  • 8
  • 24
Shubham Jaiswal
  • 359
  • 1
  • 9
  • thanks for your answer, but the fact is that if i change the calibration file, using the one i took from 8 images, it run – gaetano ma May 16 '18 at 13:34
  • Ok, for each of the 21 images could you just see the ret values. – Shubham Jaiswal May 17 '18 at 10:13
  • I have solved selecting the image of calibration. it had some in which the chessboard points were not in line but kinda sparse. do you know how to understand if a calibration is enough good? there is a parameter i can check? – gaetano ma May 17 '18 at 14:58
  • take a look at this link. it may help you. https://stackoverflow.com/questions/12794876/how-to-verify-the-correctness-of-calibration-of-a-webcam?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Shubham Jaiswal May 21 '18 at 10:07