系统版本:Ubuntu16.04
版本:opencv3.2.0
获得opencv在arm板上的库和第三方在arm上的库
推荐楷尘·极客的:opencv移植arm全过程四部曲
https://blog.csdn.net/KayChanGEEK/article/details/78543779
配套其提供的第三方依赖包更佳
https://download.csdn.net/download/kaychangeek/10120278
64位的编译第三方库时要将编译后的库放在/usr/local 的子目录下,放在其他地方有可能会编译失败
qt源码下载:http://download.qt.io/archive/qt/
我下载的版本:
qt-opensource-linux-x64-5.4.0.run 安装在Linux上的
我下载的版本是:
qt-everywhere-opensource-src-5.3.1.tar.xz 移植到arm上的板子
qt移植arm板是个坑啊,花了我很长的时间,下面这个教程我先后下载了qt5.4.0和qt5.12.0的出现了
华清远见:QT 5.3开发及移植(2)
http://emb.hqyj.com/Column/3766.html
慢慢等待make我花了一个多钟
或者
大水猫:【TINY4412】QT5移植笔记:(2)QT5.7移植到Linux
https://blog.csdn.net/sinat_20006769/article/details/79081154
编译获得opencv在linux下的库
推荐墨客墨客:Ubuntu14.04下Qt5+opencv3.0安装和配置
https://blog.csdn.net/u011831771/article/details/78482306
若出现运行程序时出现error while loading shared libraries的问题请参考
https://blog.csdn.net/weixin_41215479/article/details/88628625
qt使用其他人已经编译好的其他版本的qt库,出现qt没有被正确的安装,请运行make install,请参考:
https://blog.csdn.net/liukang325/article/details/53407401
使用其他人的库,不知道行不行。可自行尝试,我没有试过
opencv +qt在Linux上的测试用例
创建一个Qwidget
demo.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-03-17T06:02:00
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = demo2
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
INCLUDEPATH += /usr/local/include \
/usr/local/include/opencv \
/usr/local/include/opencv2
LIBS += /usr/local/lib/libopencv_highgui.so \
/usr/local/lib/libopencv_core.so \
/usr/local/lib/libopencv_highgui.so \
/usr/local/lib/libopencv_imgcodecs.so.3.2 \
/usr/local/lib/libopencv_highgui.so.3.2
widget.h和widget.cpp 不改变
main.cpp
#include "widget.h"
#include
#include
#include
#include
using namespace cv;
int main()
{
namedWindow( "src", WINDOW_AUTOSIZE );
Mat src1 = imread( "/mnt/hgfs/share/1.jpg" );
while(1)
{
imshow( "src", src1 );
char c = waitKey(30);
if( 27==c )
return 0;
}
}
出现The program has unexpectedly finished.的错误是因为图片路径问题。
添加arm版本的qt到qt应用中。atm版本的qt库在第三步中得到
遥_望:linux下如何利用QtCreator编译ARM版本的Qt程序
https://blog.csdn.net/yaowangII/article/details/78552083
arm版本的qt+arm版本的opencv在板子上运行测试用例
arm上使用opencv,如果用cvnamedwindow显示,自带的的窗口依赖gtk,可以用qt的label控件显示,先将Mat转成QImage,然后显示在label就可以了。
思路:Mat–QImage–QPixmap–QLabel
创建Qwidget
arm_demo.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-03-19T05:42:55
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = display_mat
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
INCLUDEPATH += /opt/opencv_arm/opencv-3.2.0/output/include \
/opt/opencv_arm/opencv-3.2.0/output/include/opencv \
/opt/opencv_arm/opencv-3.2.0/output/include/opencv2
LIBS += /opt/opencv_arm/opencv-3.2.0/output/lib/libopencv_highgui.so \
/opt/opencv_arm/opencv-3.2.0/output/lib/libopencv_core.so \
/opt/opencv_arm/opencv-3.2.0/output/lib/libopencv_imgcodecs.so.3.2.0 \
/opt/opencv_arm/opencv-3.2.0/output/lib/libopencv_videoio.so.3.2 \
/opt/opencv_arm/opencv-3.2.0/output/lib/libopencv_imgproc.so.3.2 \
widget.h和main.cpp不改变
widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include
#include
#include
#include
using namespace cv;
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
Mat Img;
Img = imread("1.jpg");
cvtColor(Img,Img,CV_BGR2RGB);
ui->label->setPixmap(QPixmap::fromImage(QImage(Img.data,Img.cols,Img.rows,Img.cols*Img.channels(),QImage::Format_RGB888)));
}
Widget::~Widget()
{
delete ui;
}
在widget.ui上拖拽一个label控件:objectName:label
当显示出下面这句话时就显示成功了
Failed to start program. Path or permissions wrong?
回到工程的build-arm_demo-ARM-Debug 目录
file arm_demo ,显示就是ARM文件,可将其拷贝到开发板上运行。