OpenCV with Python (cv or cv2)
Markos
markos at c2o.pro.br
Wed May 27 18:56:03 EDT 2015
Hi Laura,
On 26-05-2015 11:21, Laura Creighton wrote:
> In a message of Tue, 26 May 2015 10:24:30 -0300, Markos writes:
>
>> Hi,
>>
>> I want to use OpenCV with Python.
>>
>> I installed version 2.4.9
>> (http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/)
>> in debian Squeeze running Python 2.6.6. Using the tutorial:
>> http://indranilsinharoy.com/2012/11/01/installing-opencv-on-linux/
>>
>> (I tried to install versions 2.4.11 and 2.4.10 (in Squeeze with python
>> 2.2.6) but I couldn't.)
>>
> You mean python 2.6.6, right?
> and this package: https://packages.debian.org/source/squeeze/opencv
> which is 2.1.0-3 is too old for you?
>
>
I installed this package (python-opencv) but I thought this package
would be only some API for python to use the opencv library and I
imagined that I would still have to install the opencv library from source.
> What do you mean that you
> tried to install versions 2.4.11 and 2.4.10 but couldn't? What
> error messages did you get?
>
>
For example when trying to install the 2.4.11 version after running cmake:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D
WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D
INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON
-D WITH_QT=ON -D WITH_OPENGL=ON ..
(Output of cmake at the end of message.)
and make -j2 to compile, but an error occurred after compiling 55%:
[ 55%] Building CXX object
modules/legacy/CMakeFiles/opencv_legacy.dir/src/facedetection.cpp.o
Linking CXX shared library ../../lib/libopencv_legacy.so
[ 55%] Built target opencv_legacy
make: ** [all] Erro 2
>> I lost some time trying to load the module cv2:
>>
>>
>>>>> Import cv2.cv the cv
>>>>>
> s/the/as/ ?
>
import cv2.cv as cv
>
>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in<module>>
>> ImportError: No module named cv2.cv
>>
>> After a while I realized I could use the cv module. (import cv)
>>
>> But still I do not understand the differences between the modules cv and
>> cv2.
>>
>> Do you suggest any good tutorial about the differences between cv and cv2?
>>
>> I will have to make many changes in python programs using cv to reuse
>> the code later with cv2?
>>
>> Thanks,
>> Markos
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
> post the output you got from cmake
>
At the end of message.
> It will probably complain that it is missing some headers, so couldn't
> make libcv2.so
>
> If you haven't installed python-dev (not just python) and numpy I
> guarantee it will not find needed headers; if you have but it is
> still not being made we will have to look harder at what is going wrong.
>
>
I installed the following packages:
apt-get install cmake
apt-get install build-essential
apt-get install pkg-config
apt-get install libgtk2.0-dev
apt-get install python-opencv python-dev python-numpy
apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev libpngwriter0-dev libpngwriter0c2 zlib1g-dbg
zlib1g zlib1g-dev pngtools libjasper-dev libjasper-runtime libjasper1 libjpeg8 libjpeg8-dbg libjpeg62 libjpeg62-dev
libjpeg-progs libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools ffmpeg libavcodec-dev libavcodec52 libavformat52
libavformat-dev libswscale0 libswscale-dev openexr libopenexr6 libopenexr-dev
apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libucil2 libucil2-dev libdc1394-22-dev
libdc1394-22 libdc1394-utils libv4l-0 libv4l-dev
apt-get install libqt4-dev
> If it made a libcv.so for you, did it put it in a place you can see
> with your PYTHONPATH?
>
> Laura
>
>
>
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload',
'/usr/local/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/PIL',
'/usr/lib/python2.6/dist-packages/gst-0.10',
'/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0',
'/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode']
import cv works fine but I didn't find libcv.so in my system.
I suppose that cv had already been installed by the package
python-opencv, and the compilation of the opencv didn't install cv2.
Thanks for your attention,
Markos
Return of cmake
-- Linker flags (Release):
-- Linker flags (Debug):
-- Precompiled headers: YES
--
-- OpenCV modules:
-- To be built: core flann imgproc highgui
features2d calib3d ml video legacy objdetect photo gpu ocl nonfree
contrib stitching superres ts videostab
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: androidcamera dynamicuda java python viz
--
-- GUI:
-- QT 4.x: YES (ver 4.6.3 EDITION = OpenSource)
-- QT OpenGL support: YES (/usr/lib/libQtOpenGL.so)
-- OpenGL support: YES (/usr/lib/libGLU.so
/usr/lib/libGL.so /usr/lib/libSM.so /usr/lib/libICE.so
/usr/lib/libX11.so /usr/lib/libXext.so)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/libz.so (ver 1.2.3.4)
-- JPEG: /usr/lib/libjpeg.so (ver 62)
-- PNG: /usr/lib/libpng.so (ver 1.2.44)
-- TIFF: /usr/lib/libtiff.so (ver 42 - 3.9.4)
-- JPEG 2000: /usr/lib/libjasper.so (ver 1.900.1)
-- OpenEXR: /usr/lib/libImath.so
/usr/lib/libIlmImf.so /usr/lib/libIex.so /usr/lib/libHalf.so
/usr/lib/libIlmThread.so (ver 1.6.1)
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES (ver 2.1.2)
-- FFMPEG: YES
-- codec: YES (ver 52.123.0)
-- format: YES (ver 52.111.0)
-- util: YES (ver 50.43.0)
-- swscale: YES (ver 0.14.1)
-- gentoo-style: YES
-- GStreamer:
-- base: YES (ver 0.10.30)
-- video: YES (ver 0.10.30)
-- app: YES (ver 0.10.30)
-- riff: YES (ver 0.10.30)
-- pbutils: YES (ver 0.10.30)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l1 (ver 0.8.0) / libv4l2
(ver 0.8.0)
-- XIMEA: NO
-- Xine: NO
--
-- Other third-party libraries:
-- Use IPP: NO
-- Use Eigen: NO
-- Use TBB: NO
-- Use OpenMP: NO
-- Use GCD NO
-- Use Concurrency NO
-- Use C=: NO
-- Use Cuda: NO
-- Use OpenCL: YES
--
-- OpenCL:
-- Version: dynamic
-- Include path:
~/Programacao/Python/OpenCV/opencv-2.4.11/3rdparty/include/opencl/1.2
-- Use AMD FFT: NO
-- Use AMD BLAS: NO
--
-- Python:
-- Interpreter: /usr/bin/python2.6 (ver 2.6.6)
-- Libraries: NO
-- numpy:
/usr/lib/pymodules/python2.6/numpy/core/include (ver 1.4.1)
-- packages path: lib/python2.6/dist-packages
--
-- Java:
-- ant: NO
-- JNI: /usr/lib/jvm/java-6-sun/include
/usr/lib/jvm/java-6-sun/include/linux /usr/lib/jvm/java-6-sun/include
-- Java tests: NO
--
-- Documentation:
-- Build Documentation: NO
-- Sphinx: NO
-- PdfLaTeX compiler: /usr/bin/pdflatex
-- Doxygen: NO
--
-- Tests and samples:
-- Tests: YES
-- Performance tests: YES
-- C/C++ Examples: YES
--
-- Install path: /usr/local
--
-- cvconfig.h is in:
~/Programacao/Python/OpenCV/opencv-2.4.11/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to:
~/Programacao/Python/OpenCV/opencv-2.4.11/build
More information about the Python-list
mailing list