web-dev-qa-db-fra.com

Comment installer OpenCV for Python 3.4?

J'utilise Python 3.4 via la distribution Anaconda. Ils ne semblent pas avoir de liaisons Python 3.4 pour OpenCV. J'ai essayé d'utiliser Cmake depuis la source, mais en vain. Quelqu'un pourrait-il m'aider à installer OpenCV pour Python 3.4.x?

7
user3317287
conda install -c menpo opencv3

Fait le tour. Cependant, vous devez avoir installé Anaconda.

8
JSalys

Il existe de nombreux tutoriels et questions (sur SO) à ce sujet. 

Cela semble répondre à votre question. Edit : reproduit ci-dessous:

1)  Download OpenCV from http://opencv.org/downloads.html and extract

2)From the extracted folder, copy the file from the extracted directory:   
opencv/build/python/2.7/(either x86 or x64, depending on your Anaconda 
version)/cv2.pyd to your Anaconda site-packages directory, e.g., 
C:\Anaconda\Lib\site-packages

3)To get ffmpeg within opencv to work, you'll have to add the directory 
that ffmpeg is located in to the path (e.g., opencv/sources/3rdparty
/ffmpeg). Then you'll have to find the dll in that folder (e.g., 
opencv_ffmpeg_64.dll) and copy or rename it to a filename that includes 
the opencv version you are installing, (e.g., opencv_ffmpeg249_64) for 
2.4.9.

{Fin de la reproduction}

EDIT2 : OpenCV ne supporte pas Python 3.x à l'exception d'OpenCV version 3.0 (toujours expérimental, en version bêta). Téléchargez la version 3.0 à partir du site de téléchargement et essayez-la (merci à à cette question ).

Une SO question avec une astuce possible, si la précédente ne fonctionne pas.

Et enfin, je vous indiquerai un lisez le tutoriel de la documentation sur la façon de l’installer. </ S>

Bonne chance!

3
IronManMark20

C'est une manière assez simple:

Je recommande d'utiliser par l'anaconda.

Créez l'environnement dans Anaconda (recommandé): conda create -n deeplearning

Ensuite, activez par: activate deeplearning

Maintenant, installez opencv pour python3.x de Anaconda3 en tant que:

  • conda install -c https://conda.binstar.org/menpo opencv3

    Ceci installera simplement opencv3 et d’autres bibliothèques associées en tant que: spicy, numpy, scikit-learn et matplotlib dans cet environnement.

Vérifiez si Opencv est installé ou non en tant que:

>>> import cv2
>>> cv2.__version__
'3.1.0'
0
susan097