无效的 MEX 文件错误 CascadeClassifier_.mexmaci64,libopencv_ocl.2.4.dylib

Invalid MEX-file error CascadeClassifier_.mexmaci64, libopencv_ocl.2.4.dylib

我在 OSX 10.10。 我正在尝试 运行 使用以下库和程序的项目演示:

我在 MATLAB 中有 运行 mex -setup,它将编译器设置为 clang。

VLFeat 和 mexopencv 的路径已添加到 MATLAB 的 startup.m 文件中。

当我尝试 运行 demo_test.m 文件时,我在 MATLAB 中遇到以下错误:

Invalid MEX-file '/Users/maverick/Documents/Project/mexopencv-master/+cv/private/CascadeClassifier_.mexmaci64':
dlopen(/Users/maverick/Documents/Project/mexopencv-master/+cv/private/CascadeClassifier_.mexmaci64, 6): Symbol not found:
__ZN2cv3ocl12getOclMatRefERKNS_11_InputArrayE
  Referenced from: /usr/local/lib/libopencv_superres.2.4.dylib
  Expected in: /Applications/MATLAB_R2014b.app/bin/maci64/libopencv_ocl.2.4.dylib
 in /usr/local/lib/libopencv_superres.2.4.dylib

Error in cv.CascadeClassifier (line 33)
            this.id = CascadeClassifier_(filename);

Error in faceAlign (line 8)
    detector = cv.CascadeClassifier('haarcascade_frontalface_alt2.xml');


Error in regressionFit (line 11)
            [shape, rat, ~, init_s] = faceAlign(img, [], [], R{round_number}, b{round_number}, [], pad, [1:66], 0);


Error in demo_test (line 16)
shape = regressionFit(img, [], R, b);

我知道这个项目是有效的,因为我在另一台电脑上试过了。 我如何解决此错误并将项目添加到 运行?谢谢。

编辑 1:
这是我 运行 otool -L(相当于 ldd)...

时的输出
    $ otool -L /Applications/MATLAB_R2014b.app/bin/maci64/libopencv_ocl.2.4.dylib

/Applications/MATLAB_R2014b.app/bin/maci64/libopencv_ocl.2.4.dylib:
    @rpath/libopencv_ocl.2.4.dylib (compatibility version 2.4.0, current version 2.4.5)
    @rpath/libopencv_core.2.4.dylib (compatibility version 2.4.0, current version 2.4.5)
    @rpath/libopencv_imgproc.2.4.dylib (compatibility version 2.4.0, current version 2.4.5)
    @rpath/libopencv_objdetect.2.4.dylib (compatibility version 2.4.0, current version 2.4.5)
    @rpath/libtbb.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

编辑 2: 这是 otool -L 在 CascadeClassifier_.mexmaci64

上的输出
$ otool -L Documents/Project/mexopencv-master/+cv/private/CascadeClassifier_.mexmaci64
Documents/Project/mexopencv-master/+cv/private/CascadeClassifier_.mexmaci64:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
    /usr/local/lib/libopencv_calib3d.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_contrib.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_core.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_features2d.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_flann.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_gpu.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_highgui.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_imgproc.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_legacy.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_ml.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_nonfree.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_objdetect.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_ocl.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_photo.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_stitching.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_superres.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_video.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    /usr/local/lib/libopencv_videostab.2.4.dylib (compatibility version 2.4.0, current version 2.4.10)
    @rpath/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libmex.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libmat.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

我错过了一些图书馆吗?是不是PATH没有配置正确?

Matlab 捆绑了自己的计算机视觉库。所以它会首先尝试使用它们,即使您安装了 OpenCV。

解决方案是将这些捆绑库移动到另一个文件夹(以备万一出现问题时进行备份),然后将实际的 OpenCV 库符号 link 同步到先前由捆绑库填充的位置。

如果执行此操作后出现任何错误,则可能是因为 Matlab 再次使用了自己的库。也对这个库再次执行相同的过程。