title: OpenCV fails to find chess board corners
body: <p>I am working with an IR camera and am trying to find out if we have any lens distortion. I am using the example from OpenCV <a href="https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_calib3d/py_calibration/py_calibration.html" rel="nofollow noreferrer">here</a> to guide my work. I used a chessboard template from <a href="https://markhedleyjones.com/projects/calibration-checkerboard-collection" rel="nofollow noreferrer">here</a> and attached it to the back of a book. Before taking any images I heated the book/paper and observed that the checkerboard pattern was coming in very clear. </p>
  
  <p>I took ~50 still frames with the chessboard pattern tilted/moved so that every part of the frame contained some part of the pattern. An example of one of my images is below:</p>
  
  <p><a href="https://i.stack.imgur.com/JRpBY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JRpBY.png" alt="example calibration image"></a></p>
  
  <p>I used the following code which resulted in False for every image. I tried every combination of grid pattern sizes from (5-9, 5-9). </p>
  
  <pre><code>import numpy as np
  import cv2
  import glob2 as glob
  import matplotlib.pyplot as plt
  
  base = 'pathtoimages/'
  files = glob.glob(base + '*.png')
  
  for file in files:
      img = cv2.imread(file)
      gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
      ret, corners = cv2.findChessboardCorners(gray, (6,8), None)
  
      print (ret)
  </code></pre>
  
  <p>I can't figure out why the algorithm is not finding the corners. Any ideas?</p>
  
  <p><strong>Edit May 30, 2019:</strong></p>
  
  <p>Today I took some more images with the camera. I took the photos in a more controlled environment without any external light sources present. These new images still fail the findchessboard corner detection. I tried increasing the contrast and brightness using cv2.convertScaleAbs to produce the following image as an example. </p>
  
  <p><a href="https://i.stack.imgur.com/CfD4u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CfD4u.png" alt="Increased Contrast"></a></p>
  
  <p>This also fails. If I use cv2.goodFeaturesToTrack to find corners I get the following result:</p>
  
  <p><a href="https://i.stack.imgur.com/wWu3L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wWu3L.png" alt="corners"></a></p>
  
  <p>It seems like the Opencv corner detection algorithm is actively avoiding my chess board corners. It will find any corner it can before finding one on the chessboard. I am truly stumped here. </p>
  
  <p>As a sanity check I made sure that openCV can find the corners on the original chessboard I am using and it worked perfectly. </p>
  
  <p>Any ideas?</p>
  
  <p><strong>Edit June 4, 2019:</strong></p>
  
  <p>I ended up writing a script that allows me to manually assign each of the corners. I was able to get the camera distortion model successfully. I still have no solution for why the corners couldn't automatically be found by openCV. I think if I were to do this again in IR, I would make a custom grid that increases the contrast between grid cells simply due to differing thermal properties between "white" and "black" grid cells (use different materials). </p>