8

I'm trying to run this script:

https://github.com/openalpr/train-detector/blob/master/crop_plates.py

I've never dealt with python before. First of all I had some syntax errors in the print lines. They were lacking parentheses...but I'm not sure if I get this error because of the Python version I installed or this was indeed a syntax error. After fixing the syntax error I'm receiving the following error:

C:\>py crop_plates.py
Traceback (most recent call last):
File "crop_plates.py", line 7, in <module>
import cv2, cv
ImportError: No module named cv

I did the following:

Installed Python 2.7.5 32 bits.

Installed numpy 1.9.1 32 bits (also tried different versions)

Installed matplotlib 1.3.0.

Installed OpenCv

Copied cv2.pyd from

C:\Users\Me\Downloads\opencv\build\python\2.7\x86

to

C:\Python27\Lib\site-packages

But I can't find anywhere the cv.pyd file that I'm missing.

I found references to this guide for installing Opencv but it's not working http://opencv.willowgarage.com/documentation/python/

Thank you very much,

Edit: I'm running Python in Windows 7.

Vallo
  • 1,827
  • 2
  • 21
  • 42

4 Answers4

7

For ImportError: No module named cv, try installing opencv-python module using below command:

pip install opencv-python
JSN
  • 2,035
  • 13
  • 27
  • @Vallo - Have you checked this https://stackoverflow.com/questions/17497033/python-importerror-no-module-named-cv? – JSN Aug 14 '17 at 13:45
  • Sounds like you've to build OpenCV from source. Please see if this is helpful https://avinton.com/en/academy/install-python2-7-opencv/ – JSN Aug 14 '17 at 13:52
  • I'll give it a try. I'm running windows but I've found another guide for Windows. Thank you – Vallo Aug 14 '17 at 13:56
  • I had the error in uploading images in Wagtail 2.8. You save my time a lot! I could handle it by installing this package. Thanks! – Hamed Feb 17 '20 at 09:29
3

cv2.cv doesn't exists in OpenCV 3.0. Use simply cv2

Also, the attribute is no more CV_HOUGH_GRADIENT but HOUGH_GRADIENT

So what you looking for is probably:

cv2.HOUGH_GRADIENT
Bechilled
  • 71
  • 7
1

OK , I searched for a while and find the following :

Yasin Yousif
  • 969
  • 7
  • 23
0

It seems this code is using a old version of OpenCV. Unfortunately there is no mention of the exact version they used in their repo.

As the code is at least 2 years old, I would install opencv version 2.4.

pip install opencv-python==2.4

Fred Guth
  • 1,537
  • 1
  • 15
  • 27