Mac10.11 + Qt5.7 + OpenCV2.4.13

准备工作

  1. QT官网下载安装Qt5.7.
  2. Homebrew 官网,安装homebrew.
  3. iTerm 官网下载安装iTerm2.
  4. 启动 iTerm

    $ brew update
    $ brew info opencv
    $ brew tap homebrew/science
    $ brew install opencv --with-qt5 --with-ffmpeg --with-opengl --with-opencl

Qt 测试项目helloCV

Mac10.11 + Qt5.7 + OpenCV2.4.13_第1张图片

Mac10.11 + Qt5.7 + OpenCV2.4.13_第2张图片

Mac10.11 + Qt5.7 + OpenCV2.4.13_第3张图片

Mac10.11 + Qt5.7 + OpenCV2.4.13_第4张图片

Mac10.11 + Qt5.7 + OpenCV2.4.13_第5张图片

Mac10.11 + Qt5.7 + OpenCV2.4.13_第6张图片

Mac10.11 + Qt5.7 + OpenCV2.4.13_第7张图片

helloCV.pro 末尾添加以下代码:

INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/include/opencv
INCLUDEPATH += /usr/local/include/opencv2

LIBS += -L/usr/local/lib \
     -lopencv_core \
     -lopencv_highgui \
     -lopencv_imgproc \

main.cpp 代码如下:

//#include "mainwindow.h"
//#include 
//int main(int argc, char *argv[])
//{
//    QApplication a(argc, argv);
//    MainWindow w;
//    w.show();
//    return a.exec();
//}

#include 
#include 
#include 
using namespace std;

#include 
#include 
#include 
using namespace cv;

int main(int argc, char *argv[])
{
    Mat src = imread("/Users/tianzhaixing/Pictures/jurassic_world.jpg");
    if(src.empty())
    {
        cerr << "Please check the path of input image!" << endl;
        return -1;
    }
    const string winname = "src";
    namedWindow(winname, WINDOW_AUTOSIZE);
    imshow(winname, src);
    waitKey(0);
    destroyWindow(winname);
    return 0;
}

问题

dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /usr/local/lib/libjpeg.8.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
程序异常结束。

解决方法

参考

[1] install-opencv-3-on-yosemite-osx-10-10-x
[2] configuring-qt-for-opencv-on-osx

你可能感兴趣的:(OpenCV)