아래 설명에 나온것처럼 cmake로 mex파일을 생성할때는, visual studio sln파일을 만든 후, 그 프로젝트를 빌드한 후, INSTALL을 빌드해주면 mex파일이 생성된다.
---------------------------------------------------
Introduction
You will find the complete source code on Stereolabs’ Github page.
If you simply want to use the ZED stereo camera with Matlab (without the ZED SDK) you can refer to this article.
Prerequisites
You must have Matlab installed on your system and of course, the ZED SDK needs to be installed too.
Code
Build procedure
On Linux
Open a terminal in zed-Matlab directory and execute the following command:
export MATLAB_ROOT= /usr/local/MATLAB/R2012b mkdir build cd build cmake .. /src make make install |
On Windows
You need to set the environment variable ‘MATLAB_ROOT’, to do this you can use an editor such as ‘Rapid Environment Editor’ or use the following procedure:
- Click the Start button, right-click on ‘Computer’ and select ‘Properties’.
- Click the ‘Advanced System Settings’ link in the left column.
- In the System Properties window, click on the ‘Advanced’ tab, then click the ‘Environment Variables…’ button in the bottom of the window.
- In the upper part of the window, add your definition to ‘User variables for..’
- Click ‘New…’
- Set ‘Variable name’ as MATLAB_ROOT
- Set ‘Variable value’ to your own matlab root directory e.g. ‘C:\Program Files\MATLAB\R2014b’
- Restart your computer.
Then a common build procedure is used:
- Open cmake-gui.
- In “Where is the source code”, enter the path of the sources (e.g. ‘C:\Users\Peter\Documents\zed-matlab\src’)
- In “Where to build the binaries”, enter the build directory (e.g. ‘C:\Users\Peter\Documents\zed-matlab\build’), and click the “Configure” button.
- A dialog window asks you if CMAKE can create the folder “build” itself. Say yes.
- Another dialog window will ask you the generator of your project. Choose Visual Studio. For example, we choose “Visual Studio 12 2013”. Click the “Finish” button.
- CMAKE may take few seconds to configure the project. Then, some red lines should be displayed in the cmake-gui window.
- Make sure that the message ‘MATLAB Found, MATLAB MEX will be compiled.’ is print, if not the variable environment MATLAB_ROOT can not be found, and you can not compile the project.
- Click the “Generate” button.
- CMAKE has just generated your project in the build folder. Now, you can close the cmake-gui window and go to the build folder.
- Visual Studio files has been generated and a Visual Studio project file named “MEX.sln” too. Open it with Visual Studio.
- Right click on the project named ‘mexZED’ and select ‘Build’
- Right click on the project named ‘INSTALL’ and select ‘Build’
Run the sample
You can now find the generated MEXA file in the matlab directory (e.g. ‘\zed-matlab\matlab’), you can launch Matlab and run the ZED_Camera.m file.
'Matlab > mex' 카테고리의 다른 글
opencv mat를 matlab mex 데이터로 변환할때는 .t()로 transpose시켜줘야 한다. (0) | 2016.09.29 |
---|---|
Way to send OpenCV Mat to MATLAB workspace without copying the data? (0) | 2016.09.29 |
generate MEX-files using Visual Studio (0) | 2016.09.22 |
mex "example_mex_function.cpp" compile error (0) | 2016.09.13 |
Matlab에서 Ctrl+C 처리 (utIsInterruptPending) (0) | 2016.09.13 |