【问题标题】:Can't include OpenCV functions in Matlab in Linux不能在 Linux 的 Matlab 中包含 OpenCV 函数
【发布时间】:2014-10-25 18:12:39
【问题描述】:

我有一个 .cpp,我正在尝试在 Ubuntu 14.04 中使用 MATLAB R2011a 进行混合。该文件使用了一些 OpenCV 函数并导入了相应的库:

#include <opencv/cv.h>

我在 Matlab 中使用以下命令进行混合:

mex -I/usr/local/include FaceDetect.cpp

由于 opencv 库安装在 /usr/local/include/opencv 中。崩溃结果如下:

Warning: You are using gcc version "4.8.2-19ubuntu1)".  The version
     currently supported with MEX is "4.3.4".
     For a list of currently supported compilers see: 
     http://www.mathworks.com/support/compilers/current_release/

FaceDetect.o: In function `mexFunction':
FaceDetect.cpp:(.text+0xc6): undefined reference to `cvLoad'
FaceDetect.cpp:(.text+0x132): undefined reference to `cvCreateMemStorage'
FaceDetect.cpp:(.text+0x155): undefined reference to `cvCreateImage'
FaceDetect.cpp:(.text+0x23a): undefined reference to `cvHaarDetectObjects'
FaceDetect.cpp:(.text+0x285): undefined reference to `cvGetSeqElem'
FaceDetect.cpp:(.text+0x354): undefined reference to `cvReleaseImage'
FaceDetect.cpp:(.text+0x393): undefined reference to `cvClearMemStorage'
FaceDetect.cpp:(.text+0x39f): undefined reference to `cvReleaseHaarClassifierCascade'
collect2: error: ld returned 1 exit status

     mex: link of ' "FaceDetect.mexa64"' failed.

??? Error using ==> mex at 208
Unable to complete successfully

我尝试使用 -L 和 -lcv 进行编译,但它仍然崩溃。我做错了什么?

【问题讨论】:

  • 您的所有错误都与过时的 2009 c-api 功能有关。即 -lcv 将不再存在,您想要 -lopencv_core, -lopencv_imgproc -lopencv_highgui -lopencv_objdetect (命名通常的嫌疑人)。老实说,你的 cpp 文件的内容也可能只对垃圾箱有用。
  • 使用mexopencv
  • 使用任何有 cv::Mat 的东西。如果您在那里看到 IplImage,请继续..
  • berak 所说的 :) 确切地说,这些错误不是崩溃,而是 linking 错误。您想要链接到 OpenCV 共享库,因此请指定通常的:-L/usr/local/lib -lopencv_core ...。另外,如果您有选择,请尝试mexopencv
  • 是的,解决这个问题几乎不值得。此外,直接使用最新版本的 OpenCV(不是 matopencv)并不难。只需下载 2.4.10 二进制文件即可。只需链接每个模块的库。

标签: linux matlab opencv mex


【解决方案1】:

计算机视觉系统工具箱现在包含support package for OpenCV interface。它包括一个 MATLAB 和 OpenCV 数据类型之间的转换例程库,以及一种使用 OpenCV 编译 mex 函数的简单方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-02
    • 2014-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    • 1970-01-01
    相关资源
    最近更新 更多