Shatil Haque
Shatil Haque

Reputation: 141

ImportError: No module named cv2

import numpy as np

import cv2
from matplotlib import pyplot as plt

img = cv2.imread('1.jpg',0)

orb = cv2.ORB()

kp = orb.detect(img,None)

kp, des = orb.compute(img, kp)


img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
plt.imshow(img2),plt.show()

In here, I have installed numpy and opencv in my windows operating system. But i can't find out the proper way to add cv2 module.

Upvotes: 14

Views: 54107

Answers (2)

Lukasz Czerwinski
Lukasz Czerwinski

Reputation: 15482

The fastest and cleanest way is to run pip. It's a clean convenient tool for Python packages.

Just run:

pip install opencv-python or C:\Python27\Scripts\pip.exe install opencv-python

Upvotes: 18

101
101

Reputation: 8999

The easiest way to install OpenCV on Windows is to simply copy the cv2.pyd file into Python's site-packages directory (e.g. C:\python27\Lib\site-packages).

To get the cv2.pyd file, download and extract the latest version of the OpenCV installation executable from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ and browse the extracted folder to find the file in the relevant build directory (e.g. build\python\x86\2.7).

Upvotes: 1

Related Questions