OpenCV(3.4.1) Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file D:\Build\...

错误:OpenCV(3.4.1) Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file D:\Build\OpenCV\opencv-3.4.1\modules\imgproc\src\color.cpp, line 11147
Traceback (most recent call last):
  File "E:/pythonpro/pycv-master/chapter6/corner.py", line 6, in
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

cv2.error: OpenCV(3.4.1) D:\Build\OpenCV\opencv-3.4.1\modules\imgproc\src\color.cpp:11147: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

关于这个错误OpenCV(3.4.1) Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file D:\Build\..._第1张图片

楼主解决的方法是   :把图片路径 修改成完整路径  或者 把图片放到和.py文件同一个路径。

img = cv2.imread('images/chess_board.jpg')
img = cv2.imread('chess_board.jpg')
这下好了

你可能感兴趣的:(OpenCV(3.4.1) Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file D:\Build\...)