How to add custom Opencv library into pycharm - opencv

Basically I am developing a project using OpenVino and OpenCV,to do so I cannot use the normal and easy way of using pip to install opencv library but instead Intel provided their own optimized version OpenCV.
I cannot find a place to add the path for the custom OpenCV in pycharm.
If anybody can enlighten me,please do so.
Thank you in advance.

please try the below steps.
Install Python 2.7.10
Install Pycharm(If not installed previously)
Download the OpenCV executable.
Install OpenCV
Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
Goto C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
Goto C:\Python27\DLLs directory and paste the cv2.pyd file.
Goto C:\Python27\Lib\site-packages directory and paste the cv2.pyd file.
Goto PyCharm IDE and goto DefaultSettings>PythonInterpreter.
Select the Python which you have installed on Step1.
Install the packages numpy,matplotlib and pip in pycharm.
Restart your PyCharm.
PyCharm now has OpenCV library installed and working.
Hope this will solve your issue

Related

Problem using opencv in visual studio code

I installed openCV and vsc sees this import. However, when the program executes, an error pops up.
I have no idea where the bug is
make sure you select the right interpreter (or virtual environment)
re-select python interpreter in VSCode
reinstall the opencv library in the right interpreter:
pip3 install --force-reinstall opencv-contrib-python
also, you can use Anaconda to manage your packages

Installing OpenCV into PyCharm

Idk if this is a stackoverflow-appropriate post so forgive if the question is misplaced. I'm trying to install OpenCV into my Pycharm IDE through the conda virtual environment. I typed conda install -c conda-forge opencv inside the PyCharm terminal and it has been doing this for 11 hours and God knows how many more to go.
Pycharm did this with PyTorch as well. Am I doing something wrong or is this normal?
While you can install packages directly in PyCharm by going to file->settings select Project Interpreter and click on the '+' icon on the top right (see image)
I would recommend creating a requirements.txt file in the root of your project, and write down all your required packages. When a package is missing, PyCharm will automatically suggest to install the package for you.
e.g. for installing opencv you can add the following to you requirements.txt
opencv-python
Or even specify the version that your project needs
opencv-python==4.1.2
edit: the advantage of using a requirement.txt is that you can more easily port the project to another machine, and re-install the packages if needed.

Compiling Darknet with opencv-python

I installed Darknet with CUDA support. I ran
./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/dog.jpg
I want it to run with opencv support. I had already installed opencv.
I compiled darknet with remake/make after making OPENCV=1 in Makefile, but still it is not detecting the installed opencv.
How can I make it to detect the already installed opencv?
I have installed opencv with this command pip install opencv-python --user before installing darknet.
You need to install the c++ libraries not just the python wrapper. You can do it from the sources: https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html.
In order to compile Darknet you will need OpenCV works with C/C++ code, not python. To check whether you have installed OpenCV correctly and can be used in C program, run this command :
pkg-config --modversion opencv
If it doesn't show anything or shows wrong version, try to reinstall OpenCV OR it is possible that your machine doesn't locate opencv version correctly.
So add command to your ~/.bashrc for example :
vim ~/.bashrc
export PKG_CONFIG_PATH=/home/user/installation/OpenCV-3.4.0/lib/pkgconfig
source ~/.bashrc
Notes : Change the path according to your opencv installation directory that contains opencv.pc
If you're following this repo https://github.com/AlexeyAB/darknet for Windows/Linux you need to download openCV (both OpenCV 2.x.x and OpenCV <= 3.4.0 (3.4.1 and higher isn't supported)) and put in this path for
Windows: ( C:\opencv_3.0\opencv\build\include & C:\opencv_3.0\opencv\build\x64\vc14\lib)
More instructions in the repo. If you're on Windows/Linux and still trying to figure things out you may check a video I made on that topic https://youtu.be/-HtiYHpqnBs

Import OpenCV in Pycharm [duplicate]

This question already has answers here:
How to install OpenCV on Windows and enable it for PyCharm without using the package manager
(3 answers)
Closed 4 years ago.
I want to use OpenCV (Python module) in pycharm. I set my Python interpreter in settings and added OpenCV path (C:\opencv\build\python\2.7) to the Python interpreter path. Unfortunately pycharm couldn't import OpenCV. It's noticeable that I see the cv2.pyd in the left panel (project panel).
Can anyone help me to resolve this issue ?
Refer to How to install OpenCV on Windows and enable it for PyCharm without using the package manager
Steps to follow:
Install Python 2.7.10
Install Pycharm(If you have not done it already)
Download and install the OpenCV executable.
Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
Goto C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
Goto C:\Python27\DLLs directory and paste the cv2.pyd file.
Goto C:\Python27\Lib\site-packages directory and paste the cv2.pyd file.
Goto PyCharm IDE and goto DefaultSettings>PythonInterpreter.
Select the Python which you have installed on Step1.
Install the packages numpy,matplotlib and pip in pycharm.
Restart your PyCharm.
PyCharm now has OpenCV library installed and working.
If you have installed pycharm,then you can type :
pip install opencv-python
after satisfied,
then go to file ,setting (in pycharm)
project ,project interpreter,click on plus icon on the top right ,
search opencv-python and install package.

Kinect RGBDemo v0.6.1 in QTcreator

I would like to get this demo running in my QTcreator. I' running this on osx 10.7 and i have the latest opencv installed. I can run this demo outside the qt creator but that's all. I was wondering how to make this work as a QTcreator project.
This can be solved by opening the cmake file in qtcreator it will then load all the files an can be compiled .

Resources