title: Camera Calibration opencv python imshow error: (-215) size.width>0 && size.height>0
body: <p>For my thesis project, I need to determine the K-distortion parameters of a camera. I decided to use python and opencv to do is. So you can see I'm stell a beginner with Python and Opencv. I use this standard code:</p>
  
  <pre><code>import numpy as np
  import cv2
  import glob
  
  
  #termination criteria
  criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 70, 0.001)
  
  #prepare object points, like (0,0,0), (1,0,0) ...., (6, 4, 0)
  objp = np.zeros((7*5, 3), np.float32)
  objp[:,:2] = np.mgrid[0:5,0:7].T.reshape(-1,2)
  
  #Arrays to store objects points and real image points from all the images.
  objpoints = [] #3D point in real world space
  imgpoints = [] #2D points in image plane
  
  images = glob.glob('C:/tmp/pixelgrootte/*.jpg')
  counter = int(x=1)
  
  for fname in images:
      img = cv2.imread(fname)
      gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  
  
      #Find the chess board corners
      ret, corners = cv2.findChessboardCorners(gray, (5,7),None)
  
      # If found, add object points, image points (after refining them)
      if ret == True:
          objpoints.append(objp)
  
          corners2 = cv2.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria)
          imgpoints.append(corners2)
  
          # Draw and display the corners
          img = cv2.drawChessboardCorners(img, (5,7), corners2,ret)
          cv2.imshow('img',img)
          cv2.waitKey(500)
          counter += 1
      else:
          print("No corners found on Picture " + str(counter))
          counter += 1
  
  
  cv2.destroyAllWindows()
  
  #Calibration
  ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1],None,None)
  print("Camera Matrix: " + str(mtx))
  print("Distortion Factors: " + str(dist))
  </code></pre>
  
  <p>When I run this script, this is the error i receive: </p>
  
  <pre><code>No corners found on Picture 1
  Traceback (most recent call last):
    File "C:\Users\Lode\Documents\School\2014-2015\Thesis\Camera\Camera Calibration.py", line 37, in &lt;module&gt;
  cv2.imshow('img',img)
  error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width&gt;0 &amp;&amp; size.height&gt;0 in function cv::imshow
  </code></pre>
  
  <p>As you can see I used this standard code:<a href="https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_calib3d/py_calibration/py_calibration.html#calibration" rel="nofollow">https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_calib3d/py_calibration/py_calibration.html#calibration</a>.
  The only differences are the counter (I used it before so I could easily determine if a certain pecture was clear enough), the size of the squares (=7cm) and the shape of the checkerboard(= 8hor and 6vert squares).</p>
  
  <p>My first guess was that the imshow function didn't work but this is not the case. When I run this script, everything works just fine:</p>
  
  <pre><code>import numpy as np
  import cv2
  import glob
  
  images = glob.glob('C:/tmp/pixelgrootte/*.jpg')
  
  for fname in images:
      img = cv2.imread(fname)
      cv2.imshow('img',img)
      cv2.waitKey(500)
  
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>So then i decided to run the debugger. The debugger showed that img, imgpoints en corners2 were empty. So maybe the function cornerSubPix doesn't work in my case? But I really don't have any idea why this wouldn't work. </p>
  
  <p>Strange part about this code is that it worked perfectly two weeks ago, but since then I reinstalled my computer because it was running slow. Now, i have current versions installed:</p>
  
  <p>Windows 7 professional N 32bit</p>
  
  <p>Python 2.7.9</p>
  
  <p>Numpy 1.9.2</p>
  
  <p>Opencv 2.4.11</p>
  
  <p>So my guess is that I have a part of software needed to run this script not installed but I can't figure out what it is.  </p>
  
  <p>I already did some research on this topic but I couldn't find any solution on this forum that suited my problem. It seems like a common error but i can't figure out what causes this error. </p>
  
  <p>Is there somebody that can help me with this? I would be really grateful!</p>