import cv2
import matplotlib.pyplot as plt
%matplotlib inline
flat_chess = cv2.imread('../DATA/flat_chessboard.png')
plt.imshow(flat_chess,cmap='gray')
<matplotlib.image.AxesImage at 0x2a73ad1fa58>
found, corners = cv2.findChessboardCorners(flat_chess,(7,7))
if found:
print('OpenCV was able to find the corners')
else:
print("OpenCV did not find corners. Double check your patternSize.")
OpenCV was able to find the corners
corners.shape
(49, 1, 2)
cv2.drawChessboardCorners(flat_chess, (7, 7), corners, found)
array([[[158, 206, 255],
[158, 206, 255],
[158, 206, 255],
...,
[ 71, 139, 209],
[ 71, 139, 209],
[ 71, 139, 209]],
[[158, 206, 255],
[158, 206, 255],
[158, 206, 255],
...,
[ 71, 139, 209],
[ 71, 139, 209],
[ 71, 139, 209]],
[[158, 206, 255],
[158, 206, 255],
[158, 206, 255],
...,
[ 71, 139, 209],
[ 71, 139, 209],
[ 71, 139, 209]],
...,
[[ 71, 139, 209],
[ 71, 139, 209],
[ 71, 139, 209],
...,
[158, 206, 255],
[158, 206, 255],
[158, 206, 255]],
[[ 71, 139, 209],
[ 71, 139, 209],
[ 71, 139, 209],
...,
[158, 206, 255],
[158, 206, 255],
[158, 206, 255]],
[[ 71, 139, 209],
[ 71, 139, 209],
[ 71, 139, 209],
...,
[158, 206, 255],
[158, 206, 255],
[158, 206, 255]]], dtype=uint8)
plt.imshow(flat_chess)
<matplotlib.image.AxesImage at 0x2a73adbf2b0>
dots = cv2.imread('../DATA/dot_grid.png')
plt.imshow(dots)
<matplotlib.image.AxesImage at 0x2a73ae25080>
found, corners = cv2.findCirclesGrid(dots, (10,10), cv2.CALIB_CB_SYMMETRIC_GRID)
found
True
dbg_image_circles = dots.copy()
cv2.drawChessboardCorners(dbg_image_circles, (10,10), corners, found)
array([[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
...,
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]]], dtype=uint8)
plt.imshow(dbg_image_circles)
<matplotlib.image.AxesImage at 0x2a73ae819e8>
Keep this in mind for later lectures on camera calibration! We've only scratched the surface here :)
import jovian
jovian.commit()
[jovian] Saving notebook..