0

I am very new to python programming. I use enthought canopy (windows 7, 32-bit, version 1.3.1). Very recently I stumbled upon opencv and its capabilities. I have installed opencv but when i use it in a module, i get the following error message. I have installed opencv using this post Best way to install OpenCV on Windows with Enthought Canopy Python?

When i try running this piece of code:

picture = cv2.imread("image1.png")
picture2 = cv2.cvtColor(picture, cv2.COLOR_BGR2GRAY)

it gives an error message:

error: ..\..\..\..\opencv\modules\imgproc\src\color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

Let me know if you would need additional info

Community
  • 1
  • 1
Chandra
  • 11
  • 1
  • 1
    most likely this means, that the imread call failed silently, and your picture is empty (None) – berak Feb 16 '15 at 20:13
  • Note that opencv is available pre-built to Canopy subscribers: https://www.enthought.com/products/canopy/package-index/ . Also note that the current version of Canopy is 1.5.2 (see https://support.enthought.com/entries/61798124-Canopy-shows-no-updates-available-reinstalling-from-the-website) though that is not necessarily relevant to your problem. – Jonathan March Feb 16 '15 at 20:36
  • Is there a way I can check if Opencv has been added to the list of existing packages in enthought? and if there is a way to check if opencv is getting loaded properly? – Chandra Feb 17 '15 at 03:32

1 Answers1

0

Try with picture2 = cv2.cvtColor(picture, cv2.COLOR_GARY2BGR) if it works. Otherwise your image is not in the gray or BGL categories.

Einar Sundgren
  • 4,325
  • 9
  • 40
  • 59
Sanjay Mishra
  • 147
  • 1
  • 1
  • 8