链接OpenCV gpu :: Stereo示例时出错

时间:2016-08-30 21:54:56

标签: c++ macos qt opencv

我正在尝试编译opencv-3.0.0-beta/samples/gpu/stereo_match.cpp,但我遇到了一些链接错误:

/Users/George/Qt/5.7/clang_64/bin/qmake -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug -o Makefile ../qt-test/qt-test.pro
/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.8 -Wl,-rpath,/Users/George/Qt/5.7/clang_64/lib -o qt-test.app/Contents/MacOS/qt-test main.o mainwindow.o camviewer.o moc_mainwindow.o   -F/Users/George/Qt/5.7/clang_64/lib -L/usr/local/lib -L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib -L/Developer/NVIDIA/CUDA-7.5 -L/usr/local/Cellar/opencv3/3.1.0_3/lib -lopencv_cudabgsegm -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_stitching -lopencv_cudafeatures2d -lopencv_superres -lopencv_videostab -lopencv_cudaoptflow -lopencv_cudalegacy -lopencv_cudawarping -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_hdf -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lippicv -lopencv_highgui -lopencv_videoio -lopencv_photo -lopencv_imgcodecs -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_imgproc -lopencv_cudaarithm -lopencv_core -lopencv_cudev -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL 
Undefined symbols for architecture x86_64:
  "cv::cuda::printShortCudaDeviceInfo(int)", referenced from:
      App::App(Params const&) in main.o
  "cv::cuda::GpuMat::defaultAllocator()", referenced from:
      App::run() in main.o
      App::App(Params const&) in main.o
  "cv::cuda::GpuMat::create(int, int, int)", referenced from:
      cv::cuda::GpuMat::GpuMat(cv::Size_<int>, int, cv::cuda::GpuMat::Allocator*) in main.o
  "cv::cuda::GpuMat::upload(cv::_InputArray const&)", referenced from:
      App::run() in main.o
      App::handleKey(char) in main.o
  "cv::cuda::GpuMat::release()", referenced from:
      cv::cuda::GpuMat::~GpuMat() in main.o
  "cv::cuda::getDevice()", referenced from:
      App::App(Params const&) in main.o
  "cv::String::deallocate()", referenced from:
      cv::String::~String() in main.o
  "cv::String::allocate(unsigned long)", referenced from:
      cv::String::String(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main.o
      cv::String::String(char const*) in main.o
  "cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
      App::run() in main.o
      App::handleKey(char) in main.o
  "cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)", referenced from:
      App::run() in main.o
  "cv::cuda::GpuMat::download(cv::_OutputArray const&) const", referenced from:
      App::run() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [qt-test.app/Contents/MacOS/qt-test] Error 1
22:12:45: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qt-test (kit: Desktop Qt 5.7.0 clang 64bit)
When executing step "Make"

我正在使用Qt Creator 4.0.2和本文Configuring Qt for OpenCV on OSX中的项目文件。我根据指南通过自制软件安装了OpenCV 3.0:

  Built from source on 2016-06-24 at 23:14:16 with: --with-contrib --with-cuda --with-openni2

我已经仔细检查过,似乎安装了cuda库:

libopencv_aruco.3.1.0.dylib     libopencv_cudafilters.3.1.0.dylib   libopencv_dnn.3.1.0.dylib       libopencv_imgproc.3.1.0.dylib       libopencv_saliency.3.1.0.dylib      libopencv_video.3.1.0.dylib
libopencv_aruco.3.1.dylib       libopencv_cudafilters.3.1.dylib     libopencv_dnn.3.1.dylib         libopencv_imgproc.3.1.dylib     libopencv_saliency.3.1.dylib        libopencv_video.3.1.dylib
libopencv_aruco.dylib           libopencv_cudafilters.dylib     libopencv_dnn.dylib         libopencv_imgproc.dylib         libopencv_saliency.dylib        libopencv_video.dylib
libopencv_bgsegm.3.1.0.dylib        libopencv_cudaimgproc.3.1.0.dylib   libopencv_dpm.3.1.0.dylib       libopencv_line_descriptor.3.1.0.dylib   libopencv_shape.3.1.0.dylib     libopencv_videoio.3.1.0.dylib
libopencv_bgsegm.3.1.dylib      libopencv_cudaimgproc.3.1.dylib     libopencv_dpm.3.1.dylib         libopencv_line_descriptor.3.1.dylib libopencv_shape.3.1.dylib       libopencv_videoio.3.1.dylib
libopencv_bgsegm.dylib          libopencv_cudaimgproc.dylib     libopencv_dpm.dylib         libopencv_line_descriptor.dylib     libopencv_shape.dylib           libopencv_videoio.dylib
libopencv_bioinspired.3.1.0.dylib   libopencv_cudalegacy.3.1.0.dylib    libopencv_face.3.1.0.dylib      libopencv_ml.3.1.0.dylib        libopencv_stereo.3.1.0.dylib        libopencv_videostab.3.1.0.dylib
libopencv_bioinspired.3.1.dylib     libopencv_cudalegacy.3.1.dylib      libopencv_face.3.1.dylib        libopencv_ml.3.1.dylib          libopencv_stereo.3.1.dylib      libopencv_videostab.3.1.dylib
libopencv_bioinspired.dylib     libopencv_cudalegacy.dylib      libopencv_face.dylib            libopencv_ml.dylib          libopencv_stereo.dylib          libopencv_videostab.dylib
libopencv_calib3d.3.1.0.dylib       libopencv_cudaobjdetect.3.1.0.dylib libopencv_features2d.3.1.0.dylib    libopencv_objdetect.3.1.0.dylib     libopencv_stitching.3.1.0.dylib     libopencv_xfeatures2d.3.1.0.dylib
libopencv_calib3d.3.1.dylib     libopencv_cudaobjdetect.3.1.dylib   libopencv_features2d.3.1.dylib      libopencv_objdetect.3.1.dylib       libopencv_stitching.3.1.dylib       libopencv_xfeatures2d.3.1.dylib
libopencv_calib3d.dylib         libopencv_cudaobjdetect.dylib       libopencv_features2d.dylib      libopencv_objdetect.dylib       libopencv_stitching.dylib       libopencv_xfeatures2d.dylib
libopencv_ccalib.3.1.0.dylib        libopencv_cudaoptflow.3.1.0.dylib   libopencv_flann.3.1.0.dylib     libopencv_optflow.3.1.0.dylib       libopencv_structured_light.3.1.0.dylib  libopencv_ximgproc.3.1.0.dylib
libopencv_ccalib.3.1.dylib      libopencv_cudaoptflow.3.1.dylib     libopencv_flann.3.1.dylib       libopencv_optflow.3.1.dylib     libopencv_structured_light.3.1.dylib    libopencv_ximgproc.3.1.dylib
libopencv_ccalib.dylib          libopencv_cudaoptflow.dylib     libopencv_flann.dylib           libopencv_optflow.dylib         libopencv_structured_light.dylib    libopencv_ximgproc.dylib
libopencv_core.3.1.0.dylib      libopencv_cudastereo.3.1.0.dylib    libopencv_fuzzy.3.1.0.dylib     libopencv_photo.3.1.0.dylib     libopencv_superres.3.1.0.dylib      libopencv_xobjdetect.3.1.0.dylib
libopencv_core.3.1.dylib        libopencv_cudastereo.3.1.dylib      libopencv_fuzzy.3.1.dylib       libopencv_photo.3.1.dylib       libopencv_superres.3.1.dylib        libopencv_xobjdetect.3.1.dylib
libopencv_core.dylib            libopencv_cudastereo.dylib      libopencv_fuzzy.dylib           libopencv_photo.dylib           libopencv_superres.dylib        libopencv_xobjdetect.dylib
libopencv_cudaarithm.3.1.0.dylib    libopencv_cudawarping.3.1.0.dylib   libopencv_hdf.3.1.0.dylib       libopencv_plot.3.1.0.dylib      libopencv_surface_matching.3.1.0.dylib  libopencv_xphoto.3.1.0.dylib
libopencv_cudaarithm.3.1.dylib      libopencv_cudawarping.3.1.dylib     libopencv_hdf.3.1.dylib         libopencv_plot.3.1.dylib        libopencv_surface_matching.3.1.dylib    libopencv_xphoto.3.1.dylib
libopencv_cudaarithm.dylib      libopencv_cudawarping.dylib     libopencv_hdf.dylib         libopencv_plot.dylib            libopencv_surface_matching.dylib    libopencv_xphoto.dylib
libopencv_cudabgsegm.3.1.0.dylib    libopencv_cudev.3.1.0.dylib     libopencv_highgui.3.1.0.dylib       libopencv_reg.3.1.0.dylib       libopencv_text.3.1.0.dylib      pkgconfig
libopencv_cudabgsegm.3.1.dylib      libopencv_cudev.3.1.dylib       libopencv_highgui.3.1.dylib     libopencv_reg.3.1.dylib         libopencv_text.3.1.dylib        python2.7
libopencv_cudabgsegm.dylib      libopencv_cudev.dylib           libopencv_highgui.dylib         libopencv_reg.dylib         libopencv_text.dylib
libopencv_cudafeatures2d.3.1.0.dylib    libopencv_datasets.3.1.0.dylib      libopencv_imgcodecs.3.1.0.dylib     libopencv_rgbd.3.1.0.dylib      libopencv_tracking.3.1.0.dylib
libopencv_cudafeatures2d.3.1.dylib  libopencv_datasets.3.1.dylib        libopencv_imgcodecs.3.1.dylib       libopencv_rgbd.3.1.dylib        libopencv_tracking.3.1.dylib
libopencv_cudafeatures2d.dylib      libopencv_datasets.dylib        libopencv_imgcodecs.dylib       libopencv_rgbd.dylib            libopencv_tracking.dylib

.pro文件如下所示:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = qt-test
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    camviewer.cpp

HEADERS  += mainwindow.h \
    camviewer.h \
    tick_meter.hpp

FORMS    += mainwindow.ui

INCLUDEPATH += /Developer/NVIDIA/CUDA-7.5/include

LIBS += -L/usr/local/lib -L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib -L/Developer/NVIDIA/CUDA-7.5


QT_CONFIG -= no-pkg-config
CONFIG  += link_pkgconfig
PKGCONFIG += opencv

据我所知,我已经安装了使用CUDA的opencv 3.0并且我正在链接库,但我不确定为什么这些符号似乎丢失了。

如何双重检查我正确连接?

链接和编译此示例的正确方法是什么?

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <stdexcept>
#include <opencv2/core/utility.hpp>
#include "opencv2/cudastereo.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"

using namespace cv;
using namespace std;

bool help_showed = false;

struct Params
{
    Params();
    static Params read(int argc, char** argv);

    string left;
    string right;

    string method_str() const
    {
        switch (method)
        {
        case BM: return "BM";
        case BP: return "BP";
        case CSBP: return "CSBP";
        }
        return "";
    }
    enum {BM, BP, CSBP} method;
    int ndisp; // Max disparity + 1
};


struct App
{
    App(const Params& p);
    void run();
    void handleKey(char key);
    void printParams() const;

    void workBegin() { work_begin = getTickCount(); }
    void workEnd()
    {
        int64 d = getTickCount() - work_begin;
        double f = getTickFrequency();
        work_fps = f / d;
    }

    string text() const
    {
        stringstream ss;
        ss << "(" << p.method_str() << ") FPS: " << setiosflags(ios::left)
            << setprecision(4) << work_fps;
        return ss.str();
    }
private:
    Params p;
    bool running;

    Mat left_src, right_src;
    Mat left, right;
    cuda::GpuMat d_left, d_right;

    Ptr<cuda::StereoBM> bm;
    Ptr<cuda::StereoBeliefPropagation> bp;
    Ptr<cuda::StereoConstantSpaceBP> csbp;

    int64 work_begin;
    double work_fps;
};

static void printHelp()
{
    cout << "Usage: stereo_match_gpu\n"
        << "\t--left <left_view> --right <right_view> # must be rectified\n"
        << "\t--method <stereo_match_method> # BM | BP | CSBP\n"
        << "\t--ndisp <number> # number of disparity levels\n";
    help_showed = true;
}

int main(int argc, char** argv)
{
    try
    {
        if (argc < 2)
        {
            printHelp();
            return 1;
        }
        Params args = Params::read(argc, argv);
        if (help_showed)
            return -1;
        App app(args);
        app.run();
    }
    catch (const exception& e)
    {
        cout << "error: " << e.what() << endl;
    }
    return 0;
}


Params::Params()
{
    method = BM;
    ndisp = 64;
}


Params Params::read(int argc, char** argv)
{
    Params p;

    for (int i = 1; i < argc; i++)
    {
        if (string(argv[i]) == "--left") p.left = argv[++i];
        else if (string(argv[i]) == "--right") p.right = argv[++i];
        else if (string(argv[i]) == "--method")
        {
            if (string(argv[i + 1]) == "BM") p.method = BM;
            else if (string(argv[i + 1]) == "BP") p.method = BP;
            else if (string(argv[i + 1]) == "CSBP") p.method = CSBP;
            else throw runtime_error("unknown stereo match method: " + string(argv[i + 1]));
            i++;
        }
        else if (string(argv[i]) == "--ndisp") p.ndisp = atoi(argv[++i]);
        else if (string(argv[i]) == "--help") printHelp();
        else throw runtime_error("unknown key: " + string(argv[i]));
    }

    return p;
}


App::App(const Params& params)
    : p(params), running(false)
{
    cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());

    cout << "stereo_match_gpu sample\n";
    cout << "\nControls:\n"
        << "\tesc - exit\n"
        << "\tp - print current parameters\n"
        << "\tg - convert source images into gray\n"
        << "\tm - change stereo match method\n"
        << "\ts - change Sobel prefiltering flag (for BM only)\n"
        << "\t1/q - increase/decrease maximum disparity\n"
        << "\t2/w - increase/decrease window size (for BM only)\n"
        << "\t3/e - increase/decrease iteration count (for BP and CSBP only)\n"
        << "\t4/r - increase/decrease level count (for BP and CSBP only)\n";
}


void App::run()
{
    // Load images
    left_src = imread(p.left);
    right_src = imread(p.right);
    if (left_src.empty()) throw runtime_error("can't open file \"" + p.left + "\"");
    if (right_src.empty()) throw runtime_error("can't open file \"" + p.right + "\"");
    cvtColor(left_src, left, COLOR_BGR2GRAY);
    cvtColor(right_src, right, COLOR_BGR2GRAY);
    d_left.upload(left);
    d_right.upload(right);

    imshow("left", left);
    imshow("right", right);

    // Set common parameters
    bm = cuda::createStereoBM(p.ndisp);
    bp = cuda::createStereoBeliefPropagation(p.ndisp);
    csbp = cv::cuda::createStereoConstantSpaceBP(p.ndisp);

    // Prepare disparity map of specified type
    Mat disp(left.size(), CV_8U);
    cuda::GpuMat d_disp(left.size(), CV_8U);

    cout << endl;
    printParams();

    running = true;
    while (running)
    {
        workBegin();
        switch (p.method)
        {
        case Params::BM:
            if (d_left.channels() > 1 || d_right.channels() > 1)
            {
                cout << "BM doesn't support color images\n";
                cvtColor(left_src, left, COLOR_BGR2GRAY);
                cvtColor(right_src, right, COLOR_BGR2GRAY);
                cout << "image_channels: " << left.channels() << endl;
                d_left.upload(left);
                d_right.upload(right);
                imshow("left", left);
                imshow("right", right);
            }
            bm->compute(d_left, d_right, d_disp);
            break;
        case Params::BP: bp->compute(d_left, d_right, d_disp); break;
        case Params::CSBP: csbp->compute(d_left, d_right, d_disp); break;
        }
        workEnd();

        // Show results
        d_disp.download(disp);
        putText(disp, text(), Point(5, 25), FONT_HERSHEY_SIMPLEX, 1.0, Scalar::all(255));
        imshow("disparity", disp);

        handleKey((char)waitKey(3));
    }
}


void App::printParams() const
{
    cout << "--- Parameters ---\n";
    cout << "image_size: (" << left.cols << ", " << left.rows << ")\n";
    cout << "image_channels: " << left.channels() << endl;
    cout << "method: " << p.method_str() << endl
        << "ndisp: " << p.ndisp << endl;
    switch (p.method)
    {
    case Params::BM:
        cout << "win_size: " << bm->getBlockSize() << endl;
        cout << "prefilter_sobel: " << bm->getPreFilterType() << endl;
        break;
    case Params::BP:
        cout << "iter_count: " << bp->getNumIters() << endl;
        cout << "level_count: " << bp->getNumLevels() << endl;
        break;
    case Params::CSBP:
        cout << "iter_count: " << csbp->getNumIters() << endl;
        cout << "level_count: " << csbp->getNumLevels() << endl;
        break;
    }
    cout << endl;
}


void App::handleKey(char key)
{
    switch (key)
    {
    case 27:
        running = false;
        break;
    case 'p': case 'P':
        printParams();
        break;
    case 'g': case 'G':
        if (left.channels() == 1 && p.method != Params::BM)
        {
            left = left_src;
            right = right_src;
        }
        else
        {
            cvtColor(left_src, left, COLOR_BGR2GRAY);
            cvtColor(right_src, right, COLOR_BGR2GRAY);
        }
        d_left.upload(left);
        d_right.upload(right);
        cout << "image_channels: " << left.channels() << endl;
        imshow("left", left);
        imshow("right", right);
        break;
    case 'm': case 'M':
        switch (p.method)
        {
        case Params::BM:
            p.method = Params::BP;
            break;
        case Params::BP:
            p.method = Params::CSBP;
            break;
        case Params::CSBP:
            p.method = Params::BM;
            break;
        }
        cout << "method: " << p.method_str() << endl;
        break;
    case 's': case 'S':
        if (p.method == Params::BM)
        {
            switch (bm->getPreFilterType())
            {
            case 0:
                bm->setPreFilterType(cv::StereoBM::PREFILTER_XSOBEL);
                break;
            case cv::StereoBM::PREFILTER_XSOBEL:
                bm->setPreFilterType(0);
                break;
            }
            cout << "prefilter_sobel: " << bm->getPreFilterType() << endl;
        }
        break;
    case '1':
        p.ndisp = p.ndisp == 1 ? 8 : p.ndisp + 8;
        cout << "ndisp: " << p.ndisp << endl;
        bm->setNumDisparities(p.ndisp);
        bp->setNumDisparities(p.ndisp);
        csbp->setNumDisparities(p.ndisp);
        break;
    case 'q': case 'Q':
        p.ndisp = max(p.ndisp - 8, 1);
        cout << "ndisp: " << p.ndisp << endl;
        bm->setNumDisparities(p.ndisp);
        bp->setNumDisparities(p.ndisp);
        csbp->setNumDisparities(p.ndisp);
        break;
    case '2':
        if (p.method == Params::BM)
        {
            bm->setBlockSize(min(bm->getBlockSize() + 1, 51));
            cout << "win_size: " << bm->getBlockSize() << endl;
        }
        break;
    case 'w': case 'W':
        if (p.method == Params::BM)
        {
            bm->setBlockSize(max(bm->getBlockSize() - 1, 2));
            cout << "win_size: " << bm->getBlockSize() << endl;
        }
        break;
    case '3':
        if (p.method == Params::BP)
        {
            bp->setNumIters(bp->getNumIters() + 1);
            cout << "iter_count: " << bp->getNumIters() << endl;
        }
        else if (p.method == Params::CSBP)
        {
            csbp->setNumIters(csbp->getNumIters() + 1);
            cout << "iter_count: " << csbp->getNumIters() << endl;
        }
        break;
    case 'e': case 'E':
        if (p.method == Params::BP)
        {
            bp->setNumIters(max(bp->getNumIters() - 1, 1));
            cout << "iter_count: " << bp->getNumIters() << endl;
        }
        else if (p.method == Params::CSBP)
        {
            csbp->setNumIters(max(csbp->getNumIters() - 1, 1));
            cout << "iter_count: " << csbp->getNumIters() << endl;
        }
        break;
    case '4':
        if (p.method == Params::BP)
        {
            bp->setNumLevels(bp->getNumLevels() + 1);
            cout << "level_count: " << bp->getNumLevels() << endl;
        }
        else if (p.method == Params::CSBP)
        {
            csbp->setNumLevels(csbp->getNumLevels() + 1);
            cout << "level_count: " << csbp->getNumLevels() << endl;
        }
        break;
    case 'r': case 'R':
        if (p.method == Params::BP)
        {
            bp->setNumLevels(max(bp->getNumLevels() - 1, 1));
            cout << "level_count: " << bp->getNumLevels() << endl;
        }
        else if (p.method == Params::CSBP)
        {
            csbp->setNumLevels(max(csbp->getNumLevels() - 1, 1));
            cout << "level_count: " << csbp->getNumLevels() << endl;
        }
        break;
    }
}

更新 关于如何在Qt Creator中编译的任何提示?

1 个答案:

答案 0 :(得分:0)

感谢Miki的提示(明确地)我设法编译了样本,但仅从命令开始:

g++ stereo_match.cpp -I/usr/local/Cellar/opencv3/3.1.0_3/include/opencv -I/usr/local/Cellar/opencv3/3.1.0_3/include -L/usr/local/Cellar/opencv3/3.1.0_3/lib -lopencv_cudabgsegm -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_stitching -lopencv_cudafeatures2d -lopencv_superres -lopencv_videostab -lopencv_cudaoptflow -lopencv_cudalegacy -lopencv_cudawarping -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_hdf -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lippicv -lopencv_highgui -lopencv_videoio -lopencv_photo -lopencv_imgcodecs -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_imgproc -lopencv_cudaarithm -lopencv_core -lopencv_cudev -L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib -o stereo_match

大多数include和库标志都是通过pkg-config

生成的
pkg-config --libs --cflags /usr/local/Cellar/opencv3/3.1.0_3/lib/pkgconfig/opencv.pc 

我只需要手动添加此路径:

-L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib

因为之前的错误:

ld: library not found for -lippicv