cannot find reference for opencv functions in pycharm - python

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.

Related

Pycharm can't recognise moduls I just installed

I need to code a quick script for facial recognition. I imported the following modules (as seen in the picture below)
But pycharm says that there are no modules named face_recognition, cv2, unsolved reference path and imutils.
I don't know what the issue might be since I am super sure I installed opencv and face recognition on my laptop.
Thanks.
For example, I checked my current cv2 version and the result was this
import cv2
cv2. version
'4.7.0'

I'm getting an import error, does anyone know the solution?

hi I'm getting an import error, does anyone know the solution?
ImportError: Bindings generation error. Submodule name should always start with
a parent module name. Parent name: cv2.cv2. Submodule name: cv2
If you are using opencv-python version 4.6.0.66, try to downgrade to 4.5.5.64 version, on Pycharm you can do that by go to File->Setting->Python Interpreter-> Double-click on opencv-python version->check the specify version box, then choose older version.
Downgrade opencv also makes the auto-completion works again.
There is a bug here that seems to be what you are seeing:
https://github.com/opencv/opencv-python/issues/676

Raspberry Pi 3: OpenCV 3.4.0 missing some files after installation and can't be called within my code

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 :)

Is there no more module cv for opencv python?

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

Skimage version 0.13.1 shows import error while importing "io" module

I am using python version 3.6.2 and working on image processing. My problem is when I run python through cmd it imports io module of skimage without error but when I import it through python Idle it shows module error that no module name io. Can anyone please enlighten me why is this happening? For more understanding i'm putting screenshots of both the cases.
Through cmd:
Through Python Idle:
This problem got solved by reinstalling each and every supporting package.

Categories

Resources