How to install OpenCV ?

Hello,

I would like to install OpenCV in Paraview 5.2 (Python 2.7) for Windows (without bouilding up PV from source). Is there any document with the detailed procedure?

After looking at several blogs, I found that I have to use the windows shell and PIP (to execute pip install opencv-python). However, PIP is not recognized and I have to look for its path. Where can I find PIP in the Paraview installation folder. Im I missing something?

Thanks for your tips!

Miguel

I believe that the PV Python interpreter will pick up directories in your PYTHONPATH and load those modules (as long as the version of Python matches). So, you should be able to install opencv-python using whatever method is easiest for you, set the PYTHONPATH to point to the installation, and then run ParaView (or pvpython).

On a side note, if you want an easier method of installing python modules, you might want to look into anaconda. It make installing Python and distributions lots easier, particularly on Windows.

Hi, thanks for your answer!

I searched the PYTHONPATH variable and it was inexistent, so, I created a new one pointing to:

C:\Program Files\ParaView 5.4.1-Qt5-OpenGL2-Windows-64bit\bin

And now PIP is recognized, but when I execute:

pip install opencv-python

I have this message:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: opencv-python in c:\python27\lib\site-packages (2.4.11)

Does this mean that I can no longer install opencv in this Python version?

I also tried to change PYTHONPATH to the path mentioned in the message (it is a Python2.7 already installed in my computer that I use it with the PythonXY software). Inside this folder I can see the numpy and openCV folders.

However, when I go back to pvpython and I try to load numpy it gives an error (shown below). The same happens with opencv (Also the Python Shell fails to load numpy).

This is because the Python version used in Paraview is 2.7.3 instead of 2.7? (It should be the same thing right?)

Hopefully I can avoid the numpy error if I change PYTHONPATH back to the Python of Paraview, i.e.:

C:\Program Files\ParaView 5.4.1-Qt5-OpenGL2-Windows-64bit\bin

But I’m still without openCV…

Any sugestions? Thanks in advance!

Miguel

PS: is there any PV release with opencv included? If not, it could be interesting to consider that because it allows users to exploit Paraview as a platform for Augmented Reality projects without facing the painful processs of installing this classic package.

MESSAGE ERROR:

Traceback (most recent call last):

File “”, line 1, in

File “C:\Python27\Lib\site-packages\numpy_init_.py”, line 170, in

from . import add_newdocs

File “C:\Python27\Lib\site-packages\numpy\add_newdocs.py”, line 13, in

from numpy.lib import add_newdoc

File “C:\Python27\Lib\site-packages\numpy\lib_init_.py”, line 8, in

from .type_check import *

File “C:\Python27\Lib\site-packages\numpy\lib\type_check.py”, line 11, in

import numpy.core.numeric as _nx

File “C:\Python27\Lib\site-packages\numpy\core_init_.py”, line 6, in

from . import multiarray

ImportError: DLL load failed: %1 nÆest pas une application Win32 valide.

As you observed, Python 2 has been deprecated. This is why starting with 5.7 ParaView uses Python 3 (except on Mac for technical reasons).

I don’t know how picky Python is in mixing versions of different patch releases, but it makes sense that they would have to match. Someone who knows more about Python might have to answer that.