无效的 MEX 文件错误 CascadeClassifier_.mexmaci64、libopencv_ocl.2.4.dylib
Posted
技术标签:
【中文标题】无效的 MEX 文件错误 CascadeClassifier_.mexmaci64、libopencv_ocl.2.4.dylib【英文标题】:Invalid MEX-file error CascadeClassifier_.mexmaci64, libopencv_ocl.2.4.dylib 【发布时间】:2015-02-18 02:52:44 【问题描述】:我在 OSX 10.10 上。 我正在尝试运行使用以下库和程序的项目演示:
MATLAB R2014b 64 位。 OpenCV 2.4.10.1 通过 Homebrew 安装。 VLFeat 0.9.20。 mexopencv.我在 MATLAB 中运行了 mex -setup
,它将编译器设置为 clang。
MATLAB 的startup.m
文件中添加了 VLFeat 和 mexopencv 的路径。
当我尝试运行 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, [], [], Rround_number, bround_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 配置不正确吗?
【问题讨论】:
显然缺少此符号 __ZN2cv3ocl12getOclMatRefERKNS_11_InputArrayE。可能是 dylib 丢失或路径不正确。 寻找 opencv ocl 库。但一般情况下,如果 MATLAB 并设置LD_RUN_PATH
,您可以在外部运行 ldd mexfilw.asdf
。
@chappjc : 我从 Homebrew 安装了 OpenCV 库
@no10downingstreet 这并不意味着 mex 文件可以找到它。自己找文件
@chappjc :我没听懂你说的,抱歉。我在 OSX 上。 ldd 在 Linux 上运行。能否请您详细说明一下,我是新手。
【参考方案1】:
Matlab 捆绑了自己的计算机视觉库。因此,即使您安装了 OpenCV,它也会尝试先使用它们。
解决方案是将这些捆绑的库移动到另一个文件夹(以便在出现问题时进行备份),然后将实际的 OpenCV 库符号链接到捆绑库先前填充的位置。
如果在执行此操作后出现任何错误,则可能是因为 Matlab 再次使用了自己的库。对这个库再次执行相同的过程。
【讨论】:
以上是关于无效的 MEX 文件错误 CascadeClassifier_.mexmaci64、libopencv_ocl.2.4.dylib的主要内容,如果未能解决你的问题,请参考以下文章
MATLAB 无效的 MEX 文件错误:缺少符号 invalid_argument
无效的 MEX 文件错误 CascadeClassifier_.mexmaci64、libopencv_ocl.2.4.dylib