Closed jadorre closed 7 years ago
Those should work. What errors?
i tried many thing. First i install opencv through this pre-compiled binary and the error was importerror, multiarray, undefined symbol PyExc_SystemError. https://github.com/jabelone/OpenCV-for-Pi. So i tried to compile the binary with this tuturial http://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/ and the error was multiarray...undefined symbol "pytype_genericnew". And now i try to compile opencv with python 2.7...
With Python 2.7.9, just can't build input_opencv plugin. Same error as here : http://pastebin.com/M6Wnkcnw
I don't find the way.
I've heard of others having similar issues, and I don't really have a good answer for you. Something weird changed in the last year, and I don't personally have the time to go debug it.
Instead, if you're looking for a package that can capture images from USB devices and stream out via HTTP (among many other things), I recommend using robotpy-cscore, as it's significantly more flexible than mjpg-streamer and this plugin.
Thanks for the recommendation. I took a look at the robotpy-score code and the call to numpy looks identical which doesn't suggest anything good...
Concerning python 2.7.9, this version doesn't support the new api PyUnicode_DecodeFSDefault and that's why mjpg-streamer doesn't compile.
However, i don't understand why my installation does not work. Here's the output of the compilation :
pi@raspberrypi:/usr/src/mjpg-streamer/mjpg-streamer-experimental $ make
[ -d _build ] || mkdir _build
[ -f _build/Makefile ] || (cd _build && cmake -DCMAKE_BUILD_TYPE=Release ..)
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file sys/inotify.h
-- Looking for include file sys/inotify.h - found
-- Found OpenCV: /usr/local (found version "3.2.0") found components: core imgproc highgui videoio
-- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython3.4m.so (found version "3.4.2")
-- Found PythonInterp: /usr/bin/python3.4 (found version "3.4.2")
-- Found NUMPY: /usr/local/lib/python3.4/dist-packages/numpy/core/include
-- Found components for NumPy
-- NUMPY_ROOT_DIR = /usr/local
-- NUMPY_INCLUDES = /usr/local/lib/python3.4/dist-packages/numpy/core/include
-- NUMPY_LIBRARIES =
-- NUMPY_API_VERSION = 1.12.0
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- Checking for module 'libgphoto2'
-- No package 'libgphoto2' found
-- Could NOT find GPHOTO2 (missing: GPHOTO2_LIBRARY GPHOTO2_INCLUDE_DIR)
-- Looking for include file linux/videodev2.h
-- Looking for include file linux/videodev2.h - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
--
-- The following features have been enabled:
* PLUGIN_INPUT_FILE , File input plugin
* PLUGIN_INPUT_HTTP , HTTP input proxy plugin
* PLUGIN_INPUT_OPENCV , OpenCV input plugin
* PLUGIN_CVFILTER_CPP , OpenCV example filter
* PLUGIN_CVFILTER_PY , OpenCV python filter
* PLUGIN_INPUT_RASPICAM , Raspberry Pi input camera plugin
* PLUGIN_INPUT_UVC , Video 4 Linux input plugin
* PLUGIN_OUTPUT_FILE , File output plugin
* PLUGIN_OUTPUT_HTTP , HTTP server output plugin
* PLUGIN_OUTPUT_RTSP , RTSP output plugin
* PLUGIN_OUTPUT_UDP , UDP output stream plugin
-- The following OPTIONAL packages have been found:
* OpenCV
* PythonLibs
* PythonInterp
* Numpy
* Threads
-- The following features have been disabled:
* WXP_COMPAT , Enable compatibility with WebcamXP
* PLUGIN_INPUT_PTP2 , PTP2 input plugin (unmet dependencies)
* ENABLE_HTTP_MANAGEMENT , Enable experimental HTTP management option
* PLUGIN_OUTPUT_VIEWER , SDL output viewer plugin (unmet dependencies)
-- The following OPTIONAL packages have not been found:
* Gphoto2
* SDL
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/src/mjpg-streamer/mjpg-streamer-experimental/_build
make -C _build
make[1]: Entering directory '/usr/src/mjpg-streamer/mjpg-streamer-experimental/_build'
make[2]: Entering directory '/usr/src/mjpg-streamer/mjpg-streamer-experimental/_build'
make[3]: Entering directory '/usr/src/mjpg-streamer/mjpg-streamer-experimental/_build'
Apparently no problem but when i run this command :
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/mjpg-streamer/input_opencv.so --filter /usr/local/lib/mjpg-streamer/cvfilter_py.so --fargs /usr/src/mjpg-streamer/mjpg-streamer-experimental/plugins/input_opencv/filters/cvfilter_py/example_filter.py" -o "/usr/local/lib/mjpg-streamer/output_http.so -w /usr/local/share/mjpg-streamer/www -n"
...i always get an error :
pi@raspberrypi:~ $ sudo /usr/local/bin/mjpg_streamer -i "/usr/local/lib/mjpg-streamer/input_opencv.so --filter /usr/local/lib/mjpg-streamer/cvfilter_py.so --fargs /usr/src/mjpg-streamer/mjpg-streamer-experimental/plugins/input_opencv/filters/cvfilter_py/example_filter.py" -o "/usr/local/lib/mjpg-streamer/output_http.so -w /usr/local/share/mjpg-streamer/www -n"
MJPG Streamer Version.: 2.0
i: device........... : default
i: Desired Resolution: 640 x 480
i: filter........... : /usr/local/lib/mjpg-streamer/cvfilter_py.so
i: filter args ..... : /usr/src/mjpg-streamer/mjpg-streamer-experimental/plugins/input_opencv/filters/cvfilter_py/example_filter.py
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: /usr/local/lib/python3.4/dist-packages/numpy/core/multiarray.cpython-34m.so: undefined symbol: PyType_GenericNew
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python3.4/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.4/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.4/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.4/dist-packages/numpy/core/__init__.py", line 24, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Error loading numpy!
However, python > import numpy > numpy.version.version > give me:
'1.12.0'
and python > import cv2 > cv2.version > give me :
'3.2.0'
and opencv build correctly with :
pi@raspberrypi:~/opencv-3.2.0/build $ cmake -D CMAKE_BUILD_TYPE=RELEASE \
> -D CMAKE_INSTALL_PREFIX=/usr/local \
> -D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv_contrib-3.2.0/modules ..
-- Detected version of GNU GCC: 49 (409)
-- Looking for ccache - found (/usr/bin/ccache)
-- FP16: Compiler support is not available
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found suitable version "1.2.8", minimum required is "1.2.3")
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.8")
-- Checking for module 'gtk+-3.0'
-- No package 'gtk+-3.0' found
-- Checking for module 'libdc1394-2'
-- No package 'libdc1394-2' found
-- Checking for module 'libdc1394'
-- No package 'libdc1394' found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libgphoto2'
-- No package 'libgphoto2' found
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Caffe: NO
-- Protobuf: NO
-- Glog: NO
-- freetype2: YES
-- harfbuzz: YES
-- Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS HDF5_HL_LIBRARIES)
-- Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
-- freetype2: YES
-- harfbuzz: YES
-- Checking for modules 'tesseract;lept'
-- No package 'tesseract' found
-- No package 'lept' found
-- Tesseract: NO
-- Check contents of vgg_generated_48.i ...
-- Check contents of vgg_generated_64.i ...
-- Check contents of vgg_generated_80.i ...
-- Check contents of vgg_generated_120.i ...
-- Check contents of boostdesc_bgm.i ...
-- Check contents of boostdesc_bgm_bi.i ...
-- Check contents of boostdesc_bgm_hd.i ...
-- Check contents of boostdesc_binboost_064.i ...
-- Check contents of boostdesc_binboost_128.i ...
-- Check contents of boostdesc_binboost_256.i ...
-- Check contents of boostdesc_lbgm.i ...
--
-- General configuration for OpenCV 3.2.0 =====================================
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): /home/pi/opencv_contrib-3.2.0/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2017-02-12T09:59:58Z
-- Host: Linux 4.4.14-v7+ armv7l
-- CMake: 3.6.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/bin/c++ (ver 4.9.2)
-- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- ccache: YES
-- Precompiled headers: NO
-- Extra dependencies: /usr/lib/arm-linux-gnueabihf/libpng.so /usr/lib/arm-linux-gnueabihf/libz.so /usr/lib/arm-linux-gnueabihf/libtiff.so /usr/lib/arm-linux-gnueabihf/libjasper.so /usr/lib/arm-linux-gnueabihf/libjpeg.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 gobject-2.0 glib-2.0 fontconfig freetype gthread-2.0 gstbase-1.0 gstreamer-1.0 gstvideo-1.0 gstapp-1.0 gstriff-1.0 gstpbutils-1.0 avcodec avformat avutil swscale avresample dl m pthread rt
-- 3rdparty dependencies: libwebp IlmImf libprotobuf tegra_hal
--
-- OpenCV modules:
-- To be built: core flann imgproc ml photo reg surface_matching video dnn freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow phase_unwrapping stitching structured_light python3
-- Disabled: world contrib_world
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 viz cnn_3dobj cvv hdf matlab sfm
--
-- GUI:
-- QT: NO
-- GTK+ 2.x: YES (ver 2.24.25)
-- GThread : YES (ver 2.42.1)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.8)
-- JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver )
-- WEBP: build (ver 0.3.1)
-- PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.50)
-- TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 - 4.0.3)
-- JPEG 2000: /usr/lib/arm-linux-gnueabihf/libjasper.so (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
-- GDAL: NO
-- GDCM: NO
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: NO
-- FFMPEG: YES
-- avcodec: YES (ver 56.1.0)
-- avformat: YES (ver 56.1.0)
-- avutil: YES (ver 54.3.0)
-- swscale: YES (ver 3.0.0)
-- avresample: YES (ver 2.1.0)
-- GStreamer:
-- base: YES (ver 1.4.4)
-- video: YES (ver 1.4.4)
-- app: YES (ver 1.4.4)
-- riff: YES (ver 1.4.4)
-- pbutils: YES (ver 1.4.4)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- OpenNI2: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- Aravis SDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: NO/YES
-- XIMEA: NO
-- Xine: NO
-- gPhoto2: NO
--
-- Parallel framework: pthreads
--
-- Other third-party libraries:
-- Use IPP: NO
-- Use VA: NO
-- Use Intel VA-API/OpenCL: NO
-- Use Lapack: NO
-- Use Eigen: NO
-- Use Cuda: NO
-- Use OpenCL: YES
-- Use OpenVX: NO
-- Use custom HAL: YES (carotene (ver 0.0.1))
--
-- OpenCL: <Dynamic loading of OpenCL library>
-- Include path: /home/pi/opencv-3.2.0/3rdparty/include/opencl/1.2
-- Use AMDFFT: NO
-- Use AMDBLAS: NO
--
-- Python 2:
-- Interpreter: NO
--
-- Python 3:
-- Interpreter: /usr/bin/python3.4 (ver 3.4.2)
-- Libraries: /usr/lib/arm-linux-gnueabihf/libpython3.4m.so (ver 3.4.2)
-- numpy: /usr/local/lib/python3.4/dist-packages/numpy/core/include (ver 1.12.0)
-- packages path: lib/python3.4/dist-packages
--
-- Python (for build): /usr/bin/python3.4
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Matlab: Matlab not found or implicitly disabled
--
-- Documentation:
-- Doxygen: NO
--
-- Tests and samples:
-- Tests: YES
-- Performance tests: YES
-- C/C++ Examples: NO
--
-- Install path: /usr/local
--
-- cvconfig.h is in: /home/pi/opencv-3.2.0/build
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/opencv-3.2.0/build
What's wrong ?
mjpg-streamer's py plugin is trying to embed python inside of it, and there's something wrong about the way I went about it. Thus why it compiles, but you get errors at runtime. Figure out what that something is, and it should work.
However, cscore is a python module, so even though the numpy code is mostly the same, it's more likely to succeed because it is being used from python, so it already does the necessary things.
Hello,
You said input_opencv has been tested with OpenCV 3.1.0 but what version of python and numpy do you use? I installed OpenCV 3.1.0 with Python 3.4.2 and numpy 1.12.0 and i've got errors with these versions. Thanks
ps: sorry for my poor English :(