Я установил OpenCV 4.0 на последнюю версию Raspbian сегодня, следуя этому руководству: https://docs.opencv.org/4.0.0/d7/d9f/tutorial_linux_install.html
Я точно выполнил каждый необходимый шаг, пропустил все необязательные и выполнил cmake
без параметров.Я также установил раздетую версию, потому что у меня были проблемы с установкой полной версии.
После этого я запустил sudo apt-get install libopencv-dev
, чтобы решить некоторые проблемы с компоновщиком.
Я сейчас пытаюсь запустить простуюпрограмма для отображения изображения, но при достижении imshow
.
она имеет ошибки по умолчанию* Запуск с GDB дает такой вывод:
Thread 1 "a.out" received signal SIGSEGV, Segmentation fault.
0x76b24cdc in cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&) ()
from /usr/lib/arm-linux-gnueabihf/libopencv_highgui.so.2.4
И запуск с valgrind дает это:
==5560== Memcheck, a memory error detector
==5560== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==5560== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==5560== Command: ./a.out
==5560==
==5560== Invalid read of size 8
==5560== at 0x486603C: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb6c48b4 is 12 bytes inside a block of size 18 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4866054: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb6c5344 is 20 bytes inside a block of size 26 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865CA4: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb6cdc24 is 28 bytes inside a block of size 34 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865FC4: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb6e1d64 is 20 bytes inside a block of size 26 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560==
hello
==5560== Invalid read of size 8
==5560== at 0x4865B38: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb800e34 is 12 bytes inside a block of size 17 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865D34: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb83cfa4 is 12 bytes inside a block of size 18 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x48660C8: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb841c24 is 12 bytes inside a block of size 19 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865BC4: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb84796c is 12 bytes inside a block of size 17 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865C78: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb848850 is 8 bytes inside a block of size 14 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865FAC: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb84b8cc is 12 bytes inside a block of size 19 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865E8C: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb871790 is 8 bytes inside a block of size 15 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 8
==5560== at 0x4865BDC: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem.so)
==5560== Address 0xb8f7ec4 is 28 bytes inside a block of size 34 alloc'd
==5560== at 0x4847568: malloc (vg_replace_malloc.c:299)
==5560== by 0x6508C2F: g_malloc (in /lib/arm-linux-gnueabihf/libglib-2.0.so.0.5000.3)
==5560==
==5560== Invalid read of size 4
==5560== at 0x4CFDCDC: cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&) (in /usr/lib/arm-linux-gnueabihf/libopencv_highgui.so.2.4.9)
==5560== Address 0x1010018 is not stack'd, malloc'd or (recently) free'd
==5560==
==5560==
==5560== Process terminating with default action of signal 11 (SIGSEGV)
==5560== Access not within mapped region at address 0x1010018
==5560== at 0x4CFDCDC: cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&) (in /usr/lib/arm-linux-gnueabihf/libopencv_highgui.so.2.4.9)
==5560== If you believe this happened as a result of a stack
==5560== overflow in your program's main thread (unlikely but
==5560== possible), you can try to increase the size of the
==5560== main thread stack using the --main-stacksize= flag.
==5560== The main thread stack size used in this run was 8388608.
Я заметил вывод valgrindпоказывает, что есть недопустимые чтения перед выполнением первой строки main, так что, возможно, это источник проблемы?Я не уверен, что означает ошибка.
Я уже искал похожие проблемы в StackOverflow и не смог найти много.Пожалуйста, дайте мне знать, если я могу что-то сделать, чтобы улучшить этот вопрос.
Редактировать : Не думайте, что я ясно дал понять - программа никогда не входит в блок «ошибка чтения»,С тех пор я изменил код, чтобы он возвращался, если он действительно входит в этот блок, но он все еще является сегфагом.
Вот информация об установке:
General configuration for OpenCV 4.0.0 =====================================
Version control: unknown
Platform:
Timestamp: 2018-12-30T23:20:59Z
Host: Linux 4.14.79-v7+ armv7l
CMake: 3.7.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline:
requested: DETECT
disabled: VFPV3 NEON
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/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/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 -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 python2 python3 python_bindings_generator stitching ts video videoio
Disabled: world
Disabled by dependency: -
Unavailable: java js
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: NO
GUI:
GTK+: YES (ver 2.24.31)
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: libjpeg-turbo (ver 1.5.3-62)
WEBP: build (ver encoder: 0x020e)
PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.6.28)
TIFF: build (ver 42 - 4.0.9)
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: /home/pi/opencv-4.0.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.13)
Libraries: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.13)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.12.1)
packages path: lib/python2.7/dist-packages
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: /usr/bin/ant (ver 1.9.9)
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /usr/local
-----------------------------------------------------------------