The solutions on this question do not work with the opencv python version 3.3.1. cv2.__version__ prints 3.3.1-dev, and even import cv2.cv returns the no module error.
On reading this answer it seems like both the cv2 and cv interfaces were maintained, at least for a while but that doesn't seem the case any more.
So...
Does the cv module exist any more?
If not, then from which opencv version was this lost? And where can we find old cv functions? For instance cv.StereoRectify
Thank you
In OpenCV 3.x cv was deprecated.
Some old cv modules can be found in cv2, as cv2.stereoRectify, others are not in opencv installation anymore due to legal concerns.
You may need to pip install opencv-contrib-python --user
It seems that the old cv module has been completely removed from OpenCV in version 3.
Old functions should have been ported to the current cv2 module. In your case, it seems cv.StereoRectify is now cv2.stereoRectify
Related
I hope you're doing good.
I've been working on a robot for couple of months and got it working properly recently.
Sadly, my code got deleted including all libraries, tried to install OpenCV couple of times but I'm still getting errors
I used this link to install OpenCV 3.4.0 with the latest version of Raspbian https://www.life2coding.com/install-opencv-3-4-0-python-3-raspberry-pi-3/
ImportError: libavcodec.so.56: cannot open shared object file: No such
file or directory
Is there a proper way to install all libraries ? I'll include all libraries I used at the beginning of the code below.
Thanks in advance
[import cv2
import cv2.cv as cv
import numpy as np
from gopigo import *
import sys
import RPi.GPIO as GPIO
import time
import os
import multiprocessing as mp
Could be that you installed an old/wrong version of opencv, or it could be that you installed the base version, without the extra modules.
I would advice installing use pip, always works for me. In that case the following command should be enough:
pip install opencv-contrib-python
Note: you need to uninstall openCV first. Read more about the installation here
If you dont know what pip is, read about it and install from here
I was using 'Raspbian Stretch Lite' but didn't work, I might have missed something up while installing OpenCV library
I tried latest version of 'Raspbian Stretch with desktop and recommended software' from Raspberrypi's website https://www.raspberrypi.org/downloads/raspbian/
and followed all steps stated here to install OpenCV https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/
Once done with OpenCV use this command within your code to relocate packages
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
OpenCV is working fine to me now. Thanks to J.D. and Jayjayyy for guiding me and helping me to solve this issue, I really appreciate your help :)
I have opencv-python installed and the .pyd file is added in the site-packages and the DLLs. The code works with images. When I want to read, show, write an image it works. But I get a warning that the functions' references cannot be found in init.py . Due to this, I can not use the auto-complete feature. Could someone help me out? I am using opencv 3.4.0 and python 3.6.4 in pycharm. I downloaded opencv via pip in the command prompt.
The problem is caused by CV2 and how __init__.py does the imports. Just ignore the warnings the program will work all the same, or you can do an import with an alias like:
import cv2.cv2 as cv2
If you have a warning on it press Alt+Enter to install and fix it. Now you will have the code completion and no other warnings (about that) on the project.
Switching to an older version of opencv solved this problem for me.
Apparently pycharm sometime breaks depending on the version of opencv. For me, the newest version was, 4.6.X unstalling and installing 4.5.X did the trick.
I use python 3.10 and my newest version for opencv is 4.6.0.66 ,by changing opencv version to 4.5.5.62 and with an alias: import cv2.cv2 as cv2 my problem has solved.
Import cv2 as follows:
from cv2 import cv2
I installed version 4.5.5.64 and imported with an alias.
import cv2.cv2 as cvv2
I was using Python 3.10.2288.0 and OpenCV 1.6.0.66.
I resolved the issue by rolling back the OpenCV version to 4.5.5.62.
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.
For ImportError: No module named cv, try installing opencv-python module using below command:
pip install opencv-python
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
OK , I searched for a while and find the following :
First: you may write: import cv2.cv as cv to solve your proplem
cv and cv2 are both interface for python , and now , the newest "cv2" is the most used one , but clearly some libraries still use cv and others (like yours) use mix of the two,What is different between all these OpenCV Python interfaces?
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
I need to calculate the Earth Mover's Distance (EMD) in my program. I am trying to follow this answer, but for some reason the cv2 module which I have on my system does not have the function CalcEMD2. Could someone explain why it is missing?
I am using Anaconda for Python 3.4 and installed OpenCV with
conda install -c https://conda.anaconda.org/menpo opencv3
The package installed without problems and imports nicely.
>>> import cv2
>>> print(cv2.__version__)
3.1.0
However, CalcEMD2 does not exist. The namespace of cv2 has only two members containing the string 'emd' (case-insensitive), neither of which is the function I'm looking for:
>>> [k for k in cv2.__dict__ if 'emd' in k.lower()]
['createEMDHistogramCostExtractor', 'createEMDL1HistogramCostExtractor']
You will find it under cv2.cv.CalcEMD2() for most OpenCV 2.7.x libraries I've seen.
The compareHist() also has parameters hiding under cv2.cv.CV_COMP_* as well.
Hope this helps.
I am trying to use scikit-image to do some research. The system is Windows 7 64bit, and the python version is 2.7, 64bit.
The first program I run is from: http://scikit-image.org/
The code is
from skimage import data, io, filter
image = data.coins() # or any NumPy array!
edges = filter.sobel(image)
io.imshow(edges)
io.show()
However, the problem happens, and the error message is:
C:\Python27\lib\site-packages\skimage\io_plugins\null_plugin.py:14:
RuntimeWarning: No plugin has been loaded. Please refer to
skimage.io.plugins()
for a list of available plugins.
warnings.warn(RuntimeWarning(message))
I believe that both Python and scikit-image are correctly installed. So, may I know what is wrong with it?
Any suggestion is appreciated. Many thanks.
Just had precisely the same issue on amazon linux. The issue is that skimage requires PIL, and PIL is not installed. In the latest skimage they added the dependency, but the version that I got installed with pip didn't have it yet.
The solution is
pip install Pillow
EDIT: and after that you will probably immediately face another issue, with skimage loading image, but not being able to read it (in particular, shape being empty tuple). Here's the solution
Why does scipy.ndimage.io.imread return PngImageFile, not an array of values