Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
bbece095
Commit
bbece095
authored
Jun 19, 2013
by
hbristow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting writing Matlab testing framework
parent
31415e34
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
137 additions
and
13 deletions
+137
-13
OpenCVFindMatlab.cmake
cmake/OpenCVFindMatlab.cmake
+6
-1
CMakeLists.txt
modules/matlab/CMakeLists.txt
+10
-4
CMakeLists.txt
modules/matlab/test/CMakeLists.txt
+5
-8
OpenCVTest.m
modules/matlab/test/OpenCVTest.m
+17
-0
cv_exception.cpp
modules/matlab/test/cv_exception.cpp
+33
-0
exception.cpp
modules/matlab/test/exception.cpp
+29
-0
std_exception.cpp
modules/matlab/test/std_exception.cpp
+32
-0
testsuite.m
modules/matlab/test/testsuite.m
+5
-0
No files found.
cmake/OpenCVFindMatlab.cmake
View file @
bbece095
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
# MATLAB_FOUND: true/false
# MATLAB_FOUND: true/false
# MATLAB_ROOT_DIR: Root of Matlab installation
# MATLAB_ROOT_DIR: Root of Matlab installation
# MATLAB_MEX_SCRIPT: The mex script used to compile mex files
# MATLAB_MEX_SCRIPT: The mex script used to compile mex files
# MATLAB_BIN: The actual Matlab executable
# MATLAB_INCLUDE_DIR: Path to "mex.h"
# MATLAB_INCLUDE_DIR: Path to "mex.h"
# MATLAB_LIBRARY_DIR: Path to mex and matrix libraries
# MATLAB_LIBRARY_DIR: Path to mex and matrix libraries
# MATLAB_LIBS: The Matlab libs, usually mx, mex, mat
# MATLAB_LIBS: The Matlab libs, usually mx, mex, mat
...
@@ -119,8 +120,12 @@ function(locate_matlab_components MATLAB_ROOT_DIR)
...
@@ -119,8 +120,12 @@ function(locate_matlab_components MATLAB_ROOT_DIR)
# get the mex shell script
# get the mex shell script
find_file
(
MATLAB_MEX_SCRIPT_ NAMES mex mex.bat PATHS
${
MATLAB_ROOT_DIR
}
/bin NO_DEFAULT_PATH
)
find_file
(
MATLAB_MEX_SCRIPT_ NAMES mex mex.bat PATHS
${
MATLAB_ROOT_DIR
}
/bin NO_DEFAULT_PATH
)
# get the Matlab executable
find_file
(
MATLAB_BIN_ NAMES matlab matlab.exe PATHS
${
MATLAB_ROOT_DIR
}
/bin NO_DEFAULT_PATH
)
# export into parent scope
# export into parent scope
if
(
MATLAB_MEX_SCRIPT_ AND MATLAB_LIBS_ AND MATLAB_INCLUDE_DIR_
)
if
(
MATLAB_MEX_SCRIPT_ AND MATLAB_LIBS_ AND MATLAB_INCLUDE_DIR_
)
set
(
MATLAB_BIN
${
MATLAB_BIN_
}
PARENT_SCOPE
)
set
(
MATLAB_MEX_SCRIPT
${
MATLAB_MEX_SCRIPT_
}
PARENT_SCOPE
)
set
(
MATLAB_MEX_SCRIPT
${
MATLAB_MEX_SCRIPT_
}
PARENT_SCOPE
)
set
(
MATLAB_INCLUDE_DIR
${
MATLAB_INCLUDE_DIR_
}
PARENT_SCOPE
)
set
(
MATLAB_INCLUDE_DIR
${
MATLAB_INCLUDE_DIR_
}
PARENT_SCOPE
)
set
(
MATLAB_LIBS
${
MATLAB_LIBS_
}
PARENT_SCOPE
)
set
(
MATLAB_LIBS
${
MATLAB_LIBS_
}
PARENT_SCOPE
)
...
@@ -151,7 +156,7 @@ if (NOT MATLAB_FOUND)
...
@@ -151,7 +156,7 @@ if (NOT MATLAB_FOUND)
endif
()
endif
()
find_package_handle_standard_args
(
Matlab DEFAULT_MSG MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIR
find_package_handle_standard_args
(
Matlab DEFAULT_MSG MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIR
MATLAB_ROOT_DIR MATLAB_LIBS MATLAB_LIBRARY_DIR
MATLAB_ROOT_DIR MATLAB_LIBS MATLAB_LIBRARY_DIR
MATLAB_MEXEXT MATLAB_ARCH
)
MATLAB_MEXEXT MATLAB_ARCH
MATLAB_BIN
)
# if Matlab was not found, unset the local variables
# if Matlab was not found, unset the local variables
if
(
NOT MATLAB_FOUND
)
if
(
NOT MATLAB_FOUND
)
...
...
modules/matlab/CMakeLists.txt
View file @
bbece095
...
@@ -46,14 +46,16 @@ ocv_add_module(matlab BINDINGS opencv_core opencv_imgproc
...
@@ -46,14 +46,16 @@ ocv_add_module(matlab BINDINGS opencv_core opencv_imgproc
opencv_highgui opencv_ml opencv_calib3d opencv_photo
opencv_highgui opencv_ml opencv_calib3d opencv_photo
opencv_nonfree opencv_calib
)
opencv_nonfree opencv_calib
)
set
(
HDR_PARSER_PATH
${
OPENCV_MODULE_opencv_python_LOCATION
}
/src2
)
if
(
BUILD_TESTS
)
add_subdirectory
(
test
)
# get the include path of the Bridge
endif
()
prepend
(
"-I"
MEX_INCLUDES
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Configure time components
# Configure time components
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
set
(
HDR_PARSER_PATH
${
OPENCV_MODULE_opencv_python_LOCATION
}
/src2
)
prepend
(
"-I"
MEX_INCLUDES
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
message
(
"-- Trying to generate Matlab code"
)
message
(
"-- Trying to generate Matlab code"
)
execute_process
(
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
COMMAND
${
PYTHON_EXECUTABLE
}
...
@@ -124,3 +126,7 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
...
@@ -124,3 +126,7 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
DEPENDS opencv_matlab_sources
DEPENDS opencv_matlab_sources
)
)
endforeach
()
endforeach
()
# ----------------------------------------------------------------------------
# Install time components
# ----------------------------------------------------------------------------
modules/matlab/test/CMakeLists.txt
View file @
bbece095
# glob the source files
# run the matlab test suite
file
(
GLOB SOURCE_FILES *.cpp
)
add_test
(
opencv_matlab_test
COMMAND
${
MATLAB_BIN
}
"-nodisplay"
"-r"
"testsuite.m"
# compile each source
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
foreach
(
SOURCE_FILE_
${
SOURCE_FILES
}
)
)
get_filename_component
(
SOURCE_FILE_NAME_
${
SOURCE_FILE_
}
NAME_WE
)
add_custom_target
(
${
SOURCE_FILE_NAME_
}
ALL
${
MATLAB_MEX_SCRIPT
}
${
SOURCE_FILE_
}
)
endforeach
()
modules/matlab/test/OpenCVTest.m
0 → 100644
View file @
bbece095
% Matlab binding test cases
% Uses Matlab's builtin testing framework
classdef
OpenCVTest
<
matlab
.
unittest
.
TestCase
methods
(
Test
)
% check if the autogenerated functions can be found
function
randExists
(
testcase
)
try
cv
.
rand
();
catch
testcase
.
verifyFail
();
end
testcase
.
verifyTrue
(
true
);
end
end
end
modules/matlab/test/cv_exception.cpp
0 → 100644
View file @
bbece095
/*
* file: exception.cpp
* author: Hilton Bristow
* date: Wed, 19 Jun 2013 11:15:15
*
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
*/
#include <exception>
#include <opencv2/core.hpp>
#include "mex.h"
/*
* exception
* Gateway routine
* nlhs - number of return arguments
* plhs - pointers to return arguments
* nrhs - number of input arguments
* prhs - pointers to input arguments
*/
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
// call the opencv function
// [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
try
{
throw
cv
::
exception
;
}
catch
(
cv
::
exception
&
e
)
{
mexErrMsgTxt
(
e
.
what
());
}
catch
(...)
{
mexErrMsgTxt
(
"Incorrect exception caught!"
);
}
}
modules/matlab/test/exception.cpp
0 → 100644
View file @
bbece095
/*
* file: exception.cpp
* author: Hilton Bristow
* date: Wed, 19 Jun 2013 11:15:15
*
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
*/
#include "mex.h"
/*
* exception
* Gateway routine
* nlhs - number of return arguments
* plhs - pointers to return arguments
* nrhs - number of input arguments
* prhs - pointers to input arguments
*/
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
// call the opencv function
// [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
try
{
throw
1
;
}
catch
(...)
{
mexErrMsgTxt
(
"Uncaught exception occurred!"
);
}
}
modules/matlab/test/std_exception.cpp
0 → 100644
View file @
bbece095
/*
* file: exception.cpp
* author: Hilton Bristow
* date: Wed, 19 Jun 2013 11:15:15
*
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
*/
#include <exception>
#include "mex.h"
/*
* exception
* Gateway routine
* nlhs - number of return arguments
* plhs - pointers to return arguments
* nrhs - number of input arguments
* prhs - pointers to input arguments
*/
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
// call the opencv function
// [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
try
{
throw
std
::
exception
();
}
catch
(
std
::
exception
&
e
)
{
mexErrMsgTxt
(
e
.
what
());
}
catch
(...)
{
mexErrMsgTxt
(
"Incorrect exception caught!"
);
}
}
modules/matlab/test/testsuite.m
0 → 100644
View file @
bbece095
%setup the tests
opencv_tests
=
OpenCVTest
();
%run the tests
result
=
run
(
opencv_tests
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment