import cv2
import os
for filename in os.listdir('C:/Users/Akhil/Downloads/New'):
image = cv2.imread(filename)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imwrite('gray_image.png',gray_image)
cv2.imshow('color_image',image)
cv2.imshow('gray_image',gray_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
I am importing all the images from a directory as shown above and turning each image into a grey scale image. But when I run this code, I am facing the following error:
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::ipp_cvtColor, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgproc\src\color.cpp, line 7456
Traceback (most recent call last):
File "11.py", line 7, in <module>
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.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