Qt & OpenCV Learning (i)

Source: Internet
Author: User

Qt did not learn how to system, OPENCV also did not learn the system. Take your time, and make it clear one step at a time.

Sky Embedded Technology has a document, the first to see this document, mainly the development environment configuration. The document name is the QT application Development manual -20150918.pdf. Set the cross compiler in QT and set the path of the qmake. Qmake is to generate the makefile file, the cross compiler compiles the program according to makefile and generates the executable file.

Use QT creater to create a new project, any application. The steps to compile this program are as follows.

1) Open the terminal.
2) Cd/root/helloembedsky into the project source directory:/root/helloembedsky.
3) Execute source/opt/embedsky/qt-4.5/setarm_env
4) Execute $qmake
5) Execute make
6) also generate Helloembedsky, put the program on the Development Board to use./HELLOEMBEDSKY-QWS can be run up.
What is the content of/opt/embedsky/qt-4.5/setarm_env?

The content is as follows: This is where many environment variables are set. $QMAKE to use these environment variables.

#!/bin/sh

Export Qpedir=/opt/embedsky/qt-4.5/__install/arm/bin
Export Qtopia_depot_path=/opt/embedsky/qt-4.5/__install/arm/bin
Export Qtdir=/opt/embedsky/qt-4.5/__install/arm/bin
Export Dqtdir=/opt/embedsky/qt-4.5/__install/arm/bin
Export Qmake=/opt/embedsky/qt-4.5/__install/arm/bin/qmake
Export Uic=/opt/embedsky/qt-4.5/__install/arm/bin/uic
Export Tmakedir=/opt/embedsky/qt-4.5/__install/arm/bin
Export Tmakepath= $TMAKEDIR/lib/qws/linux-arm-g++
Export path= $QPEDIR/bin: $QTDIR/bin: $DQTDIR/bin: $TMAKEDIR/bin: $PATH
Export ld_library_path= $QPEDIR/lib: $QTDIR/lib: $DQTDIR/lib: $LD _library_path

Follow the steps above to successfully compile an embedded QT application. The prerequisite is that you have the QT creater installed and the cross compiler installed.

Well, the embedded QT can be used, how to use the content of OpenCV in Qt. There are two main points, one, the first file contains two, link library dynamic loading

After compiling the OPENCV will get the Include folder, this file has two folders OpenCV and Opencv2. Copy the Include folder as a whole into the current project directory.

The second one is the dynamic link library, libopencv_core.so libopencv_highgui.so libopencv_imgproc.so These three files are OpenCV compiled after the obtained. These 3 files are placed in the/opt/embedsky/4.4.6/lib directory.

Since you want to increase the use of the OpenCV library function, it is certainly in the project's makefile file, add the above header file path and dynamic link insecure library download. First look at the above works generated by the makefile file, the above operation of the section (4) After the $qmake, you get makefile. Below is the content of makefile, the file is longer, the important part is extracted.

CC = ARM-LINUX-GCC
CXX = arm-linux-g++
defines =-dqt_no_debug-dqt_gui_lib-dqt_network_lib-dqt_core_lib-dqt_shared
CFLAGS =-pipe-o2-wall-w-d_reentrant $ (defines)
Cxxflags =-pipe-o2-wall-w-d_reentrant $ (defines)
  Incpath=-i/opt/embedsky/qt-4.5/__install/arm/mkspecs/default-i.-i/opt/embedsky/qt-4.5/__install/arm/include/qtcore-i/ opt/embedsky/qt-4.5/__install/arm/include/qtnetwork-i/opt/embedsky/qt-4.5/__install/arm/include/qtgui-i/opt/ Embedsky/qt-4.5/__install/arm/include-i.-isrc-iinclude-iinclude/opencv-iinclude/opencv2-I.-I.
LINK = arm-linux-g++
Lflags =-wl,-o1-wl,-rpath,/opt/embedsky/qt-4.5/__install/arm/lib.
  LIBS= $ (sublibs)-l/opt/embedsky/qt-4.5/__install/arm//lib-l.-lopencv_core-lopencv_highgui-lopencv_imgproc-lqtgui-l/tslib-1.4/libc-l/opt/embedsky/qt-4.5/__install/arm//lib-lts-lqtnetwork-lqtcore-lm-lrt-ldl-lpthread
AR = Arm-linux-ar CQS
Ranlib =
QMAKE =/opt/embedsky/qt-4.5/__install/arm/bin/qmake

The contents of the above makefile have been changed by me, noting the black bold and red parts. Incpath is the included path at compile time, and Libs is the dynamically linked library.

The above Incpath adds 3 header file lookup locations, and 3 additional library files are added to the following Libs. Here the library is relative link, draw Zhang.

Qt & OpenCV Learning (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.