Generally do not want to use Caffe Matlab interface, always feel that the Linux version of MATLAB is difficult to configure, but now engage in target detection, the source code is used Caffe Matlab interface, can only bite the bullet on the.
(1) Modify Caffe-master/makefile.config
This step is mainly to add the path to MATLAB in Caffe's compiled configuration file makefile.config. Note The path folder is the "bin" folder that you want to include in the MATLAB installation directory.
(2) Compile the interface. Here the default has been compiled Caffe source body part. So the interface is compiled directly. Open the terminal in the Caffe-master directory, enter: Make Matcaffe as to how to compile the main part of the Caffe source code, please Baidu, that is, do all, do test those. I did not add the MATLAB path in the makefile.config at first, so the MATLAB interface will not compile when compiling the Caffe body code.
(3) test the interface. Enter Make Mattest
There may be an error: caffe_.mexa64:undefined symbol:
_zn2cv8imencodeerknst7__cxx1112basic_stringicst11char_traitsicesaiceeerkns_11_ Inputarrayerst6vectorihsaiheerksb_iisaiiee
The cause of the error is that there is a conflict between the MATLAB library and the Ubuntu System library, and the use of the Ubuntu Library is not a word.
PS: Only replacing library libstdc++.so.6 is not possible, to resolve this problem requires replacing several libraries. Input Terminal command:
Export LD_PRELOAD=/USR/LIB/X86_64-LINUX-GNU/LIBOPENCV_HIGHGUI.SO.2.4:/USR/LIB/X86_64-LINUX-GNU/LIBOPENCV_ imgproc.so.2.4:/usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/ Lib/x86_64-linux-gnu/libfreetype.so.6
Export ld_library_path=/usr/lib/x86_64-linux-gnu/
This depends on the specific directory, I wrote a script here, as follows:
Export LD_LIBRARY_PATH=/USR/LIB/X86_64-LINUX-GNU/:/USR/LOCAL/CUDA-8.0/LIB64LD_PRELOAD=/USR/LIB/X86_64-LINUX-GNU /libopencv_highgui.so.2.4:/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4:/usr/lib/x86_64-linux-gnu/ Libopencv_core.so.2.4:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libfreetype.so.6 Matlab
Note: The directory/usr/lib/x86_64-linux-gnu/is my system library directory. You can determine your system library directory by querying the location of your library:
sudo find/-name libstdc++.so.6
Re-run make mattest, problem solving ~
(4) Try the interface in MATLAB
<1> Download Bvlc_reference_caffenet.caffemodel
Links: Http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel
Download it and put it in the folder/caffe-master/models/bvlc_reference_caffenet this is because a running demo will use this model.
<2> in Terminal input command "MATLAB" (can't open itself to add path) open matlab, switch to directory/caffe-master/matlab/demo/(this is important)
<3> Enter command run (' CLASSIFICATION_DEMO.M ') or double-tap to open CLASSIFICATION_DEMO.M directly click "Run" on the console above, no input parameters required.
The <4> output is a 1000x1 matrix because the Imagenet dataset has 1000 categories.
OK, everybody cheer ~
Resources:
How to install the Matlab API in Caffe
http://blog.csdn.NET/buyi_shizi/article/details/51607109
A call to the Caffe interface under MATLAB
http://blog.csdn.Net/u012746763/article/details/50419153
Matlab interface for compiling Caffe under Ubuntu