Problem in load library when using opencv and matlab

http://blog.cordiner.net/2010/02/15/opencv-viola-jones-object-detection-in-matlab/ describes how to use OpenCv with matlab. I tried to execute the following command given at the end of the page :
opencvPath = 'C:\Program Files (x86)\OpenCV1.1';
includePath = fullfile(opencvPath, 'cxcore\include');
loadlibrary(...
fullfile(opencvPath, 'bin\cxcore110.dll'), ...
fullfile(opencvPath, 'cxcore\include\cxcore.h'), ...
'mfilename', 'proto_cxcore');
loadlibrary(...
fullfile(opencvPath, 'bin\cv110.dll'), ...
fullfile(opencvPath, 'cv\include\cv.h'), ...
'alias', 'cv110', 'includepath', includePath);
loadlibrary(...
fullfile(opencvPath, 'bin\highgui110.dll'), ...
fullfile(opencvPath, 'otherlibs\highgui\highgui.h'), ...
'alias', 'highgui110', 'includepath', includePath);
classifierFilename = 'C:/Program Files (x86)/OpenCV1.1/data/haarcascades/haarcascade_frontalface_alt.xml';
cvCascade = calllib('cv110', 'cvLoadHaarClassifierCascade', classifierFilename, ...
libstruct('CvSize',struct('width',int16(100),'height',int16(100))));
However,it returns an error ??? Error using ==> loadlibrary at 279 Microsoft Visual C++ 2005 or 2008 is required to use this feature.
Error in ==> opencv_test_prototype at 4
loadlibrary(...
I have Visual Studio 2010 Express as well as 2008 installed and have worked with MEX files before. I dont know how to proceed. Kindly help

回答(2 个)

8 个评论

I am running the program on R2011a but the answer in the link is applicable for older versions of matlab. Could u be more clear please.Thanx
Try running the command "mex -setup" in MATLAB and allow the utility to automatically locate installed compilers. Is it able yo find one of your installed Visual Studio compilers? If yes, select them, and try loadlibrary again.
Hi Kaustubha,I did what you said but its the same thing,same load library error.I have 2010 also and I performed mex -setup and it showed Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2010 Express in c:\Program Files (x86)\Microsoft Visual Studio 10.0
[2] Microsoft Visual C++ 2008 SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 2,
Now on selecting 2 it shows Error: Could not find the 64-bit compiler. This may indicate that the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit MEX-files
Microsoft Visual C++ 2008 requires that these two packages are
installed properly.
*****************************************************************************
Trying to update options file: C:\Users\Sumona\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2010b\bin\win64\mexopts\msvc90opts.bat
Done . . .
But load library error repeats and it mentions that I must have 2008. Now I selected second time VS2010 but the error remains. So, do I have to install those missing Microsoft Windows Software
Development Kit (SDK) although my system has SDK7.1. Please explain what to do.Thanx
VS2008 requires SDK 6.1 I believe.
Chitra: You do see the message "Error: Could not find the 64-bit compiler. This may indicate that the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit MEX-files
Microsoft Visual C++ 2008 requires that these two packages are
installed properly. " - which means that you did not install the "X64 Compilers and Tools" package when you installed Visual Studio - these are needed to compiler 64-bit binaries (by default, Visual Studio can only compiler 32-bit binaries). See if re-installing this Visual Studio package fixes the loadlibrary issue.
And like Walter recommend, you also need the appropriate SDK.
Hi Kaustubha and Walter: I followed all the steps described in link http://www.mathworks.com/support/solutions/en/data/1-6IJJ3L/?solution=1-6IJJ3L . Now in mex setup there is no error(the prev err Could not find 64 bit compiler etc vanished). However,the load library error remains! What else is left to do now?
Chitra - you mentioned in your previous comment that you are using R2011a, but from the output of your "mex -setup" it shows that you are using R2010b, which is older than R2011a. The previous discussion I pointed to in my original answer is applicable to you.

请先登录,再进行评论。

Failed to find OpenCV libraries in C:\opencv\build\x64\mingw\lib
Dont know what the error is ?Capture.PNG

提问:

2012-2-4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by