Here is what i observed when I used my own image sets in .jpg
format. In the sample script available in Opencv doc, note that it has the undistort
and crop the image
lines as below:
# undistort
dst = cv2.undistort(img, mtx, dist, None, newcameramtx)
# crop the image
x,y,w,h = roi
dst = dst[y:y+h, x:x+w]
cv2.imwrite('calibresult.jpg',dst)
So, when we run the code for the first time, it executes the line cv2.imwrite('calibresult.jpg',dst)
saving a image calibresult.jpg
in the current directory. So, when I ran the code for the next time, along with my sample image sets that I used for calibrating the camera in jpg format, the code also tried to consider this newly added image calibresult.jpg
due to which the error popped out
error: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgproc\src\color.cpp:7456: error: (-215) scn == 3 || scn == 4 in function cv::ipp_cvtColor
What I did was: I simply deleted that newly generated image after each run or alternatively changed the type of the image to say png
or tiff
type. That solved the problem. Check if you are inputting and writing calibresult
of the same type. If so, just change the type.