Add OpenCV configuration in Qt in Linux

Source: Internet
Author: User
First, Qt has been successfully installed in linux, and I use Ubuntu10. Next I will talk about it in this environment, if there are differences, install them according to the specific version. First, open Ubuntu10.10's Software Center, as shown in. Click Ubuntu Software Center. The following window appears. Enter opencv in the search box in the upper right corner. Many related software installations are displayed, except for the first one, after installation

First, Qt has been successfully installed in linux, and I use Ubuntu10. Next I will talk about it in this environment, if there are differences, install them according to the specific version.

First, open the Software Center of Ubuntu 10.10, as shown in:

 

Click Ubuntu Software Center. The following window is displayed.

 

Enter opencv in the search box in the upper right corner to display a lot of related installation software. Except for the first one, it has no effect on the running program.

After installation, enter the following command in the command line: sudo gedit/usr/share/qt4/mkspecs/default/qmake. conf.
The following two sentences are added to the file:
QMAKE_INCDIR =/usr/include/opencv
QMAKE_LIBS =-lcvaux-lcv-lcxcore-lhighgui-lml


The following example is used to test whether the installation is successful:

# Include
# Include

Int main ()
{
IplImage * img = 0;
Img = cvLoadImage ("test.jpg",-1); // test.jpg is under the directory of the project created
CvNamedWindow ("test", 1 );
CvShowImage ("test", img );
CvWaitKey (0 );
Return 0;
}

Step 1: qmake-project

Step 2: qmake

Step 3: Open the XXX. pro file and run the command vi XXX. pro to add the following content:

INCLUDEPATH + =/usr/include/opencv

LIBS + =/usr/lib/libcv. so \
/Usr/lib/libcvaux. so \
/Usr/lib/libcxcore. so \
/Usr/lib/libhighgui. so \
/Usr/lib/libml. so

Step 4: make

Step 5: run the command:./XXX to check whether the image is successfully output.

Related Article

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.