ARM——Bus error
各位前辈,小弟最近试着将opencv一直到ARM板上,搞完之后,想要测试一下一直成功了没,写了个测试程序(qt+opencv),在虚拟机上跑没问题,经过交叉编译后,在板子上运行,总是提示Bus error,然后没有其他提示,实在无从下手,望高手能够指点一下!程序代码如下:
#include <QtGui/QApplication>
#include<QtGui/QImage>
#include<QtGui/QWidget>
#include<QtGui/QLabel>
#include<QtGui/QVBoxLayout>
#include<opencv2/opencv.hpp>
using namespace cv;
static QImage Mat2QImage(Mat& image)
{
QImage img;
if (image.channels()==3) {
cvtColor(image, image, CV_BGR2RGB);
img = QImage(image.data, image.cols, image.rows,
image.cols*image.channels(), QImage::Format_RGB888);
} else if (image.channels()==1) {
img = QImage(image.data, image.cols, image.rows,
image.cols*image.channels(), QImage::Format_ARGB32);
} else {
img = QImage(image.data, image.cols, image.rows,
image.cols*image.channels(), QImage::Format_RGB888);
}
return img;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *wn = new QWidget;
wn->setWindowTitle("disp image");
Mat image=imread("lena.jpg");
QImage img = Mat2QImage(image);
QLabel *label = new QLabel("", 0);
label->setPixmap(QPixmap::fromImage(img));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
wn->setLayout(layout);
wn->show();
return a.exec();
}