0

error Traceback (most recent call last) in () ----> 1 gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

error: /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:10638: error: (-215) scn == 3 || scn == 4 in function cvtColor

  • Possible duplicate of [How to interpret c++ opencv Assertion error messages due to an error in cvtColor function?](https://stackoverflow.com/questions/32027849/how-to-interpret-c-opencv-assertion-error-messages-due-to-an-error-in-cvtcolor) – Miki Nov 09 '17 at 20:36
  • Your `image` is not a 3 or 4 channel image. print its `shape` – Miki Nov 09 '17 at 20:37
  • can you tell me how to do it? – Shrinidhi Goswami Nov 09 '17 at 20:41
  • 1
    a little effort plase... https://stackoverflow.com/a/19098258/5008845 – Miki Nov 09 '17 at 20:42

1 Answers1

1

One possibility is that the image you are trying to read is not in the path you provided. OpenCV doesn't throw an error in this case but just returns a none type.

Now, when you try to convert the none type to a gray image, you get the above error.

Check out the image i have posted. In this code, 'a.jpg' does not exist in the default path.

MK 62665
  • 123
  • 1
  • 8