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.
The Python "ModuleNotFoundError: No module named 'cv2'" occurs when we forget to install the opencv-python module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install opencv-python command.
The file cv2.so is stored in /usr/local/lib/python2.7/site-packages/... There are also folders in /usr/local/lib called python3.2 and python2.6, which could be a problem but I'm not sure.
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
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
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With