본문 바로가기

카테고리 없음

Qt 5.0: Developing Qt Applications For Mac

I have created a simple Qt application that uses OpenCV to capture frames from a webcam and display them using QGraphicsView. A screenshot is shown below. To get instant access the code for the application please to our weekly newsletter Install OpenCV For this tutorial I am assuming you have installed OpenCV 2 or OpenCV 3. If you have not, you can install them using Homebrew. The basic installation commands are shown below. Install OpenCV 2.4.x on OSX using Homebrew brew tap homebrew/science brew install opencv Install OpenCV 3 on OSX using Homebrew brew tap homebrew/science brew install opencv3 You can find detailed instructions for by clicking. Using OpenCV 3 in a Qt application is a bit tricky for OSX because opencv and opencv3 packages contain the same libraries and so opencv3 is not deployed to /usr/local/lib like other packages.

I will help you navigate through these complexities. Install Qt Creator You can download and follow the onscreen instructions for installing it.

DevelopingQt 5.0 developing qt applications for mac os x

There are some restrictions on using Qt in a commercial application and you should make sure you know about licensing issues. You may find this helpful. Build settings for Qt / OpenCV project The very first thing to do is instruct Qt where to find pkg-config. The default location for pkg-config is /usr/local/bin. Which pkg-config # returns /usr/local/bin/pkg-config We need to add /usr/local/bin to PATH. Go to Project, expand Build Environment and add /usr/local/bin to PATH. Don’t forget to add a colon (:) before appending /usr/local/bin!

See the screenshot below. Qt build settings for OpenCV If you are using OpenCV 3 you also need to add a new variable called PKGCONFIGPATH and set it to the directory that contains opencv.pc for your OpenCV 3 installation. You can find it using the following command find /usr/local -name 'opencv.pc' # /usr/local/Cellar/opencv3/3.1.03/lib/pkgconfig/opencv.pc You may not need the above step for OpenCV 2.4.x.

Qt 5.0 Developing Qt Applications For Mac Os X

How to modify Qt project file (.pro ) for OpenCV Now that the paths are correctly set up, we need to add a few lines to our project file (.pro) to tell qmake to use pkg-config for OpenCV. # The following lines tells Qmake to use pkg-config for opencv QTCONFIG -= no-pkg-config CONFIG += linkpkgconfig PKGCONFIG += opencv If you are using OpenCV 3, the compiler may complain ld: library not found for -lippicv How to fix compiler error “ld: library not found for -lippicv” The ippicv library the compiler is complaining about is actually included in your OpenCV installation, but it is not in the right path.