我正在尝试在Fedora 23计算机上编译以下C代码(gcc版本5.3.1 20151207(Red Hat 5.3.1-2)(GCC))并且它没有给出任何错误。程序运行。
然而,当我在Raspberry Pi 1 Model B +(gcc版本4.9.2(Raspbian 4.9.2-10))上编译相同的代码时,编译器没有错误但在运行时崩溃。可能有人弄清楚,哪里是问题?
还附加了调试信息。
/* Compile with
* gcc -lm opencv_video_isolated.c -o ooopencv_video_isolated `pkg-config --cflags --libs opencv`
*/
#include <stdio.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <X11/Xlib.h>
int main()
{
CvCapture* capture;
capture = cvCreateCameraCapture(0);
IplImage* frame;
/* Capture a single frame from the video stream */
frame = cvQueryFrame( capture );
double ab = frame->depth;
double ac = frame->width;
double ad = frame->height;
return 0;
}
我也在Raspberry Pi上粘贴了GDB输出。
(gdb) file opencv_video_isolated
Reading symbols from opencv_video_isolated...done.
(gdb) run
Starting program: /home/.../src/opencv_video_isolated
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0xb30ec270 (LWP 1523)]
Program received signal SIGSEGV, Segmentation fault.
0x00012718 in main () at opencv_video_isolated.c:22
22 double ab = frame->depth;
(gdb) backtrace
#0 0x00012718 in main () at opencv_video_isolated.c:22
(gdb)
答案 0 :(得分:2)
Program received signal SIGSEGV, Segmentation fault.
您想要print frame
。最有可能的是NULL
。然后,您需要弄清楚您违反cvQueryFrame
或cvCreateCameraCapture
的前提条件。