For more time than I am willing to admit, I have tried getting the Beaglebone Black up and running with OpenCV and a camera. However, having compiled OpenCV 4.0.0/3.4.6/3.4.0 manually and trying to initialize a camera using the Python bindings, it continue to fail.
Using v4l2-ctl I can both view and set formats etc. from the terminal, but when trying something as simple as
import cv2
vs = cv2.VideoCapture(0)
retVal, frame = vs.read()
this yields:
>> select timeout
>> VIDIOC_DQBUF: Resource temporarily unavailable
Camera works perfectly fine on a Raspberry Pi and my PC, and funny thing - on the Beaglebone I tried to install OpenCV using apt-get which made the camera work just fine.
So
sudo apt-get install python-opencv
which installs OpenCV 3.2.0 (without any hardware optimizations for arm) works..
Would any of you happen to know what I am missing here? Is there simply a bug in OpenCV or am I missing something for my build?
For more information I have attached my build overview below:
cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-D ENABLE_NEON=ON
-D ENABLE_VFPV3=ON
-D BUILD_TESTS=OFF
-D INSTALL_PYTHON_EXAMPLES=OFF
-D BUILD_EXAMPLES=OFF
-D WITH_JPEG=ON
-D BUILD_JPEG=OFF
-D JPEG_INCLUDE_DIR=/opt/libjpeg-turbo/include/
-D JPEG_LIBRARY=/opt/libjpeg-turbo/lib32/libjpeg.a
-D WITH_V4L=ON ..
-- Looking for ccache - not found
-- FP16 is not supported by C++ compiler
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found suitable version "1.2.8", minimum required is "1.2.3")
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.8")
-- Checking for module 'gstreamer-base-1.0'
-- No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
-- No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
-- No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
-- No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
-- No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-base-0.10'
-- No package 'gstreamer-base-0.10' found
-- Checking for module 'gstreamer-video-0.10'
-- No package 'gstreamer-video-0.10' found
-- Checking for module 'gstreamer-app-0.10'
-- No package 'gstreamer-app-0.10' found
-- Checking for module 'gstreamer-riff-0.10'
-- No package 'gstreamer-riff-0.10' found
-- Checking for module 'gstreamer-pbutils-0.10'
-- No package 'gstreamer-pbutils-0.10' found
-- Checking for module 'libdc1394-2'
-- No package 'libdc1394-2' found
-- Checking for module 'libdc1394'
-- No package 'libdc1394' 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 'libavresample'
-- No package 'libavresample' found
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
-- A library with BLAS API found.
-- A library with LAPACK API found.
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- OpenCV Python: during development append to PYTHONPATH: /mnt/ext2/opencv-4.0.0/build/python_loader
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/filter.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- Excluding from source files list: modules/calib3d/src/undistort.avx2.cpp
--
-- General configuration for OpenCV 4.0.0 =====================================
-- Version control: unknown
--
-- Platform:
-- Timestamp: 2019-04-14T12:06:42Z
-- Host: Linux 4.14.71-ti-r80 armv7l
-- CMake: 3.7.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
--
-- CPU/HW features:
-- Baseline: VFPV3 NEON
-- requested: DETECT
-- required: VFPV3 NEON
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/local/bin/c++ (ver 6.3.0)
-- 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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/local/bin/gcc
-- 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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfp16-format=ieee -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- ccache: NO
-- Precompiled headers: YES
-- Extra dependencies: dl m pthread rt
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python3 python_bindings_generator stitching ts video videoio
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: java js python2
-- Applications: perf_tests apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- GTK+: YES (ver 3.22.11)
-- GThread : YES (ver 2.50.3)
-- GtkGlExt: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.8)
-- JPEG: /opt/libjpeg-turbo/lib32/libjpeg.a (ver 62)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.6.28)
-- TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 / 4.0.8)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: YES
-- avcodec: YES (ver 57.64.101)
-- avformat: YES (ver 57.56.101)
-- avutil: YES (ver 55.34.101)
-- swscale: YES (ver 4.2.100)
-- avresample: NO
-- GStreamer: NO
-- v4l/v4l2: linux/videodev2.h
--
-- Parallel framework: pthreads
--
-- Trace: YES (built-in)
--
-- Other third-party libraries:
-- Lapack: NO
-- Eigen: NO
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /mnt/ext2/opencv-4.0.0/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.5.3)
-- Libraries: /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.3)
-- numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.12.1)
-- packages path: lib/python3.5/dist-packages
--
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
which looks somewhat fine to me.
Edit 1
I have now tried to compile OpenCV 3.4.6 with v4l2, ffmpeg and gstreamer1.0. This now gives me the error:
import cv2
vs = cv2.VideoCapture(0)
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.153063] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.268158] Process v4l2src0:src (pid: 1377, stack limit = 0xdaefc218)
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.274715] Stack: (0xdaefdc30 to 0xdaefe000)
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.279094] dc20: daefdc8c daefdc40 c0a1abdc c0a0ad6c
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.287311] dc40: bf1c65c8 c0a1abb0 daefdc8c 00000001 bf1d1800 014000c0 00000005 db616900
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.295528] dc60: 0000001a db215000 00000000 ffffff92 c1504dc8 00000000 c0ae3820 00000012
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.303746] dc80: daefdcac daefdc90 bf1c7e4c c0a1abb0 db2153ac db215608 db2153ac c1504dc8
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.311963] dca0: daefdccc daefdcb0 bf1c2f20 bf1c7d58 db2154e4 db215608 db2153ac c1504dc8
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.320181] dcc0: daefdcec daefdcd0 bf174740 bf1c2f00 db2153ac 00000000 00000001 c1504dc8
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.328399] dce0: daefdd04 daefdcf0 bf175e10 bf1746e0 db21565c db2153ac daefdd14 daefdd08
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.336616] dd00: bf192224 bf175ce4 daefdd34 daefdd18 bf1c3358 bf1921f0 db215394 db215000
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.344834] dd20: 00000001 c1504dc8 daefdd54 daefdd38 bf1c45ec bf1c3330 bf1c45a8 40045612
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.353051] dd40: db215010 c1504dc8 daefdd6c daefdd58 c0ae384c bf1c45b4 00000001 40045612
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.361269] dd60: daefddd4 daefdd70 c0ae6460 c0ae382c dadd7ea0 dad82e38 00000001 bf1cc5d0
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.369486] dd80: c15ceea4 dc546f00 daefddfc dc546f00 c9fe0000 dad82e38 daefddc4 00000051
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.377703] dda0: c1504dc8 322c3fc2 daefddfc 40045612 c1504dc8 00000000 daefddfc 00000004
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.385921] ddc0: ae1d37d0 00000000 daefdeac daefddd8 c0ae5d58 c0ae61b4 c02bffec 00000000
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.394137] dde0: 00000000 00000000 00000001 c0ae61a8 db2c0300 00000000 daefde24 00000001
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.402355] de00: daefde50 00000000 00012003 322c3fc2 00000000 c1504dc8 daefde48 00000000
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.410572] de20: ffffffff 00000001 00000001 c01dc5d8 daefde8c daefde40 c01dc5d8 c01dc304
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.418789] de40: daefde6c daefde50 00000001 daefde48 ad80e000 daea1a80 00000190 322c3fc2
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.427006] de60: daefded4 c1504dc8 00000001 00000000 ad80e124 ad80e190 00000001 322c3fc2
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.435223] de80: daefdf4c db215010 db2c0300 40045612 ae1d37d0 00000000 00000006 00000000
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.443439] dea0: daefdebc daefdeb0 c0ae61a4 c0ae5ae0 daefdee4 daefdec0 c0ae21d0 c0ae6190
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.451656] dec0: c1504dc8 ae1d37d0 db2c0300 40045612 daa69c00 00000006 daefdf7c daefdee8
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.459874] dee0: c030de50 c0ae210c daefdfac 322c3fc2 c1504dc8 daefdf3c ab070000 00000003
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.468090] df00: daea1a80 00000000 daefdf74 daefdf18 c02a4de4 c0351c3c 00000001 c031affc
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.476307] df20: db2c0300 00000006 daefdf5c daefdf38 c031affc c01b68d0 14892100 b3996a18
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.484525] df40: 00000000 40045612 ae1d37d0 322c3fc2 daefdf6c 00000000 db2c0301 db2c0300
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.492742] df60: 40045612 ae1d37d0 00000006 00000000 daefdfa4 daefdf80 c030e758 c030dd9c
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.500960] df80: 14892100 b3996a18 00000000 00000036 c01090e4 daefc000 00000000 daefdfa8
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.509178] dfa0: c0108f00 c030e6e8 14892100 b3996a18 00000006 40045612 ae1d37d0 00000001
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.517395] dfc0: 14892100 b3996a18 00000000 00000036 b6fc4ce8 b6fc4ce8 b6fc4ce8 ae2ab000
Message from syslogd@beaglebone at Apr 16 06:21:01 ...
kernel:[ 127.525612] dfe0: ae1d37d0 ae1d37c0
ae2957c9 b6e1e1c2 00070030 00000006 00000000 00000000