Permalink
Browse files

Fixed win64 issue; Fixed doc error;

  • Loading branch information...
1 parent d3e98bb commit 1b686fe866fccdc197574d7595f152aedfb14036 @kyamagu committed Aug 22, 2012
Showing with 65 additions and 58 deletions.
  1. +1 −1 +cv/calcGlobalOrientation.m
  2. +36 −37 +cv/make.m
  3. +28 −20 README.markdown
@@ -1,6 +1,6 @@
%CALCGLOBALORIENTATION Calculates a global motion orientation in a selected region
%
-% o = cv.calcMotionGradient(orientation, mask, mhi, timestamp, duration)
+% o = cv.calcGlobalOrientation(orientation, mask, mhi, timestamp, duration)
%
% ## Input
% * __orientation__ Motion gradient orientation image calculated by the function
View
@@ -11,26 +11,25 @@ function make(varargin)
cwd = pwd;
cd(fileparts(fileparts(mfilename('fullpath'))));
-
+
if ispc % Windows
% Clean
if nargin>0 && strcmp(varargin{1},'clean')
- cmd = sprintf('delete +cv\\*.%s +cv\\private\\*.%s',mexext,mexext);
+ cmd = sprintf('delete +cv\\*.%s +cv\\private\\*.%s', mexext, mexext);
disp(cmd);
eval(cmd);
return;
end
-
+
opencv_path = 'C:\opencv';
for i = 1:2:nargin
- if strcmp(varargin{i},'opencv_path')
+ if strcmp(varargin{i}, 'opencv_path')
opencv_path = varargin{i+1};
end
end
-
mex_flags = sprintf('-largeArrayDims -D_SECURE_SCL=%d -Iinclude %s',...
- true, pkg_config(opencv_path));
-
+ true, pkg_config(opencv_path));
+
% Compile MxArray
force = false;
src = 'src\\MxArray.cpp';
@@ -41,35 +40,35 @@ function make(varargin)
eval(cmd);
force = true;
end
-
- if ~exist(dst,'file')
- error('cv:make','lib\MxArray.obj not found');
+
+ if ~exist(dst, 'file')
+ error('cv:make', 'lib\MxArray.obj not found');
end
-
+
% Compile other files
srcs = dir('src\+cv\*.cpp');
- srcs = cellfun(@(x) regexprep(x,'(.*)\.cpp','$1'), {srcs.name},...
- 'UniformOutput', false);
+ srcs = cellfun(@(x) regexprep(x,'(.*)\.cpp', '$1'), {srcs.name},...
+ 'UniformOutput', false);
psrcs = dir('src\+cv\private\*.cpp');
- psrcs = cellfun(@(x) regexprep(x,'(.*)\.cpp','private\\$1'), {psrcs.name},...
- 'UniformOutput', false);
+ psrcs = cellfun(@(x) regexprep(x,'(.*)\.cpp', 'private\\$1'), ...
+ {psrcs.name}, 'UniformOutput', false);
srcs = [srcs,psrcs];
for i = 1:numel(srcs)
src = sprintf('src\\+cv\\%s.cpp', srcs{i});
dst = sprintf('+cv\\%s', srcs{i});
- fulldst = [dst '.' mexext];
+ fulldst = [dst, '.', mexext];
if compile_needed(src, fulldst) || force
cmd = sprintf('mex %s %s lib\\MxArray.obj -output %s',...
- mex_flags,src, dst);
+ mex_flags, src, dst);
disp(cmd);
eval(cmd);
else
fprintf('Skipped %s\n', src);
end
end
else % Unix
- system(sprintf('make MATLABDIR=%s%s',matlabroot,...
- sprintf(' %s',varargin{:})));
+ system(sprintf('make MATLABDIR=%s%s', matlabroot,...
+ sprintf(' %s', varargin{:})));
end
cd(cwd);
@@ -81,20 +80,18 @@ function make(varargin)
%
function s = pkg_config(opencv_path)
%PKG_CONFIG constructs OpenCV-related option flags for Windows
- if nargin < 1, opencv_path = 'C:\opencv'; end
- L_path = sprintf('%s\\build\\%s\\%s\\lib',opencv_path,arch_str,compiler_str);
- I_path = sprintf('%s\\build\\include',opencv_path);
-
- l_options = cellfun(@(x) ['-l',x,' '], lib_names(L_path),...
- 'UniformOutput', false);
+ L_path = sprintf('%s\\build\\%s\\%s\\lib',
+ opencv_path, arch_str, compiler_str);
+ I_path = sprintf('%s\\build\\include', opencv_path);
+ l_options = cellfun(@(x) ['-l', x, ' '], lib_names(L_path),...
+ 'UniformOutput', false);
l_options = [l_options{:}];
-
- s = sprintf('-I"%s" -L"%s" %s',I_path,L_path,l_options);
+ s = sprintf('-I"%s" -L"%s" %s', I_path, L_path, l_options);
end
function s = arch_str
%ARCH_STR return architecture used in mex
- if isempty(strfind(mexext,'64'))
+ if isempty(strfind(mexext, '64'))
s = 'x86';
else
s = 'x64';
@@ -104,26 +101,28 @@ function make(varargin)
function s = compiler_str
%COMPILER_STR return compiler shortname
c = mex.getCompilerConfigurations;
- if ~isempty(strfind(c.Name,'Visual'))
- if ~isempty(strfind(c.Version,'10.0')) % vc2010
+ if ~isempty(strfind(c.Name, 'Visual'))
+ if ~isempty(strfind(c.Version, '10.0')) % vc2010
s = 'vc10';
- elseif ~isempty(strfind(c.Version,'9.0')) % vc2008
+ elseif ~isempty(strfind(c.Version, '9.0')) % vc2008
s = 'vc9';
else
- error('cv:make','Unsupported compiler');
+ error('cv:make', 'Unsupported compiler');
end
- elseif ~isempty(strfind(c.Name,'GNU'))
+ elseif ~isempty(strfind(c.Name, 'Microsoft SDK')) % win64
+ s = 'vc10';
+ elseif ~isempty(strfind(c.Name, 'GNU'))
s = 'mingw';
else
- error('cv:make','Unsupported compiler');
+ error('cv:make', 'Unsupported compiler');
end
end
function l = lib_names(L_path)
%LIB_NAMES return library names
- d = dir([L_path,'\opencv_*d.lib']);
- l = cellfun(@(x) regexprep(x,'(opencv_.+)d.lib','$1'),{d.name},...
- 'UniformOutput',false);
+ d = dir([L_path, '\opencv_*d.lib']);
+ l = cellfun(@(x) regexprep(x, '(opencv_.+)d.lib','$1'), {d.name},...
+ 'UniformOutput',false);
end
function r = compile_needed(src, dst)
View
@@ -9,7 +9,6 @@ Matlab's native data type and OpenCV data types. The package is suitable for
fast prototyping of OpenCV application in Matlab, use of OpenCV as an external
toolbox in Matlab, and development of an original mex function.
-
Contents
========
@@ -29,14 +28,13 @@ The project tree is organized as follows.
test/ directory for test scripts and resources
utils/ directory for utilities
-
Compile
=======
Prerequisite:
* Unix: matlab, opencv (>=2.3.1), g++, make, pkg-config
- * Windows: matlab, opencv (>=2.3.1), Visual C++ (2010 recommended)
+ * Windows: matlab, opencv (>=2.3.1), supported compiler
Note: opencv (>=2.1.0) is partially supported.
@@ -60,39 +58,52 @@ Optionally you can test the library functionality
$ make test
-If matlab says 'Library not loaded' in the test, it's likely the compatibility
-issue between a system library and matlab's internal library. You might be able
-to fix this issue by preloading the library file. On linux, set the correct
-library path in `LD_PRELOAD` environmental variable. On Mac OS X, this variable
-is named `DYLD_INSERT_LIBRARIES`.
+If matlab says 'Library not loaded' or any other error in the test, it's likely
+the compatibility issue between a system library and matlab's internal library.
+You might be able to fix this issue by preloading the library file. On linux,
+set the correct library path in `LD_PRELOAD` environmental variable. For
+example, if you see `GLIBCXX_3.4.15` error in mex, use the following to start
+matlab.
+
+ $ LD_PRELOAD=/usr/lib/libstdc++.so.6 matlab
+
+On Mac OS X, this variable is named `DYLD_INSERT_LIBRARIES`. You can check
+`ldd` command line tool to check the dependency of the mex file in linux. On
+mac, you can use `otool -L` command.
Developer documentation can be generated with doxygen if installed
$ make doc
This will create html and latex files under `doc/`.
-
Windows
-------
Make sure you have OpenCV installed in the system and correctly set up `Path`
-system variable. (See http://opencv.willowgarage.com/wiki/ ) Then, in the matlab
-shell, type
+system variable. e.g., `c:\opencv\build\x86\vc10\bin`. See
+http://opencv.willowgarage.com/wiki/ for the instruction.
+Also make sure you install a compiler supported by Matlab. See
+http://www.mathworks.com/support/sysreq/previous_releases.html for the list of
+supported compilers for different versions of Matlab. Windows 64-bit users need
+to install Windows SDK.
+
+Once you satisfy the above requirement, in the matlab shell, type
>> cv.make
to build all mex functions. By default, mexopencv assumes the OpenCV library is
-installed in `C:\opencv`. If this is different, specify the path as an argument.
+installed in `C:\opencv`. If this is not the case, specify the path as an
+argument.
>> cv.make('opencv_path', 'c:\your\path\to\opencv')
Note that if you build OpenCV from source, this path specification does not
-work. You need to modify `+cv/make.m` to correctly link your mex files with
-the library. Or, you need to replace dll files in the OpenCV package with
-newly built files.
+work. You need to replace dll files in the OpenCV package with newly built
+binaries. Or, you need to modify `+cv/make.m` to correctly link your mex files
+with the library.
-To remove built binaries, use the following command.
+To remove existing mexopencv binaries, use the following command.
>> cv.make('clean')
@@ -126,7 +137,6 @@ If you see `Invalid MEX file` error even when having the matched `_SECURE_SCL`
flag, it probably indicates some other compatibility issues. Please file a bug
report at http://github.com/kyamagu/mexopencv .
-
Usage
=====
@@ -180,7 +190,6 @@ located inside `test` directory.
addpath('test');
UnitTest;
-
Developing a new mex function
=============================
@@ -194,7 +203,7 @@ The minimum contents of the myfunc.cpp would look like this:
{
// Check arguments
if (nlhs!=1 || nrhs!=1)
- mexErrMsgIdAndTxt("myfunc:invalidArgs","Wrong number of arguments");
+ mexErrMsgIdAndTxt("myfunc:invalidArgs", "Wrong number of arguments");
// Convert MxArray to cv::Mat
cv::Mat mat = MxArray(prhs[0]).toMat();
@@ -250,7 +259,6 @@ mex function, define your class at `+cv/MyClass.m` and develop a mex function
dedicated for that class in `src/+cv/private/MyClass_.cpp`. Inside of
`+cv/MyClass.m`, you can call `MyClass_()` without cv namescope.
-
Testing
-------

0 comments on commit 1b686fe

Please sign in to comment.