| 
 | 
 
我用opencv+qt4.5写的在arm上调用摄像头的程序,PC上linux环境下可以正常使用,但在arm上运行时显示segmentation fault。 
请问该如何解决呢?以下是代码: 
main.cpp: 
#include <QtGui/QApplication> 
#include "widget.h" 
 
int main(int argc, char *argv[]) 
{ 
    QApplication a(argc, argv); 
    Widget w; 
    w.show(); 
 
    return a.exec(); 
} 
 
////////////////////////////////////////////////// 
widget.h: 
#ifndef WIDGET_H 
#define WIDGET_H 
 
#include <QWidget> 
#include "highgui.h" 
#include "cv.h" 
#include <QTimer> 
#include <QImage> 
 
using namespace std; 
#define TIME_LOCK 30 
#define FPS 10 
namespace Ui { 
    class Widget; 
} 
 
class Widget : public QWidget 
{ 
    Q_OBJECT 
 
public: 
    explicit Widget(QWidget *parent = 0); 
    ~Widget(); 
 
private: 
    Ui::Widget *ui; 
    IplImage *frame; 
    CvCapture *capture; 
    QTimer *timer; 
    QImage *img; 
private slots: 
    void slot_timer(); 
protected: 
    void paintEvent(QPaintEvent *event); 
}; 
 
#endif // WIDGET_H 
 
/////////////////////////////////////// 
widget.cpp: 
#include "widget.h" 
#include "ui_widget.h" 
#include <QPainter> 
 
Widget::Widget(QWidget *parent) : 
    QWidget(parent), 
    ui(new Ui::Widget) 
{ 
    ui->setupUi(this); 
    timer = new QTimer(this); 
    connect(timer,SIGNAL(timeout()),this,SLOT(slot_timer())); 
    timer->start(FPS); 
    capture=cvCreateCameraCapture(0); 
 
} 
 
Widget::~Widget() 
{ 
    delete ui; 
    cvReleaseImage(&frame); 
} 
void Widget::slot_timer() 
{ 
    frame=cvQueryFrame(capture); 
    if(!frame) 
    { 
        return; 
    } 
    cvCvtColor(frame,frame,CV_BGR2RGB); 
    img=new QImage((unsigned char*)frame->imageData,frame->width,frame->height,frame->widthStep,QImage::Format_RGB888); 
    update(); 
 
} 
void Widget::paintEvent(QPaintEvent *event) 
{ 
    QPainter *pp=new QPainter(this); 
    pp->drawImage(0,0,*img); 
} 
 
另外如果调用摄像头的话还可以用什么方法呢? 
我的是TQ2440,使用V4L2很卡。 
 
 |   
 
 
 
 |