0
votes

I am new to the opencv library

I was trying to apply the tutorial for camera calibration however I receive the error that 'gray' is not defined when I use the function cv.cameraCalibrate.

I am afraid that the images are not being read ? Even when I tried to load some checkerboard photos from a directory , still the same problem

you can find the link for the tutorial here https://docs.opencv.org/3.4/dc/dbb/tutorial_py_calibration.html

2
gray seems to be there: gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) Are you sure all the indentations are as they should be? - Micka
Yes, it is identical - Hesham.K

2 Answers

1
votes

The images are not able to load. As a result, for loop is not iterating over the array of images and hence the gray variable inside the loop is never been initialized. So it is showing undefined for gray variable. Check if your images array is empty then cross-check the path from where you are loading the images.

0
votes

This is an error you get when the images are not imported correctly. Check whether the images you are trying to import are in the same folder as your python script. If they are not and you don't want to move them, you can specify the path to the directory you want the script to look for.