vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
set(TEST_PROXY ${CMAKE_CURRENT_BINARY_DIR}/test.proxy)
|
||||
file(REMOVE ${TEST_PROXY})
|
||||
|
||||
# generate
|
||||
# call the python executable to generate the Matlab gateways
|
||||
add_custom_command(
|
||||
OUTPUT ${TEST_PROXY}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/OpenCVTest.m ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testsuite.m ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${TEST_PROXY}
|
||||
COMMENT "Building Matlab tests"
|
||||
)
|
||||
|
||||
# targets
|
||||
# opencv_matlab_sources --> opencv_matlab
|
||||
add_custom_target(opencv_test_matlab ALL DEPENDS ${TEST_PROXY})
|
||||
add_dependencies(opencv_test_matlab ${the_module})
|
||||
|
||||
# run the matlab test suite
|
||||
add_test(opencv_test_matlab
|
||||
COMMAND ${MATLAB_BIN} "-nodisplay" "-r" "testsuite.m"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
@@ -0,0 +1,166 @@
|
||||
% Matlab binding test cases
|
||||
% Uses Matlab's builtin testing framework
|
||||
classdef OpenCVTest < matlab.unittest.TestCase
|
||||
|
||||
methods(Test)
|
||||
|
||||
% -------------------------------------------------------------------------
|
||||
% EXCEPTIONS
|
||||
% Check that errors and exceptions are thrown correctly
|
||||
% -------------------------------------------------------------------------
|
||||
|
||||
% check that std exception is thrown
|
||||
function stdException(testcase)
|
||||
try
|
||||
std_exception();
|
||||
testcase.verifyFail();
|
||||
catch
|
||||
% TODO: Catch more specific exception
|
||||
testcase.verifyTrue(true);
|
||||
end
|
||||
end
|
||||
|
||||
% check that OpenCV exceptions are correctly caught
|
||||
function cvException(testcase)
|
||||
try
|
||||
cv_exception();
|
||||
testcase.verifyFail();
|
||||
catch
|
||||
% TODO: Catch more specific exception
|
||||
testcase.verifyTrue(true);
|
||||
end
|
||||
end
|
||||
|
||||
% check that all exceptions are caught
|
||||
function allException(testcase)
|
||||
try
|
||||
exception();
|
||||
testcase.verifyFail();
|
||||
catch
|
||||
% TODO: Catch more specific exception
|
||||
testcase.verifyTrue(true);
|
||||
end
|
||||
end
|
||||
|
||||
% -------------------------------------------------------------------------
|
||||
% SIZES AND FILLS
|
||||
% Check that matrices are correctly filled and resized
|
||||
% -------------------------------------------------------------------------
|
||||
|
||||
% check that a matrix is correctly filled with random numbers
|
||||
function randomFill(testcase)
|
||||
sz = [7 11];
|
||||
mat = zeros(sz);
|
||||
mat = cv.randn(mat, 0, 1);
|
||||
testcase.verifyEqual(size(mat), sz, 'Matrix should not change size');
|
||||
testcase.verifyNotEqual(mat, zeros(sz), 'Matrix should be nonzero');
|
||||
end
|
||||
|
||||
function transpose(testcase)
|
||||
m = randn(19, 81);
|
||||
mt1 = transpose(m);
|
||||
mt2 = cv.transpose(m);
|
||||
testcase.verifyEqual(size(mt1), size(mt2), 'Matrix transposed to incorrect dimensionality');
|
||||
testcase.verifyLessThan(norm(mt1 - mt2), 1e-8, 'Too much precision lost in tranposition');
|
||||
end
|
||||
|
||||
% multiple return
|
||||
function multipleReturn(testcase)
|
||||
A = randn(10);
|
||||
A = A'*A;
|
||||
[V1, D1] = eig(A); D1 = diag(D1);
|
||||
[~, D2, V2] = cv.eigen(A);
|
||||
testcase.verifyLessThan(norm(V1 - V2), 1e-6, 'Too much precision lost in eigenvectors');
|
||||
testcase.verifyLessThan(norm(D1 - D2), 1e-6, 'Too much precision lost in eigenvalues');
|
||||
end
|
||||
|
||||
% complex output from SVD
|
||||
function complexOutputSVD(testcase)
|
||||
A = randn(10);
|
||||
[V1, D1] = eig(A);
|
||||
[~, D2, V2] = cv.eigen(A);
|
||||
testcase.verifyTrue(~isreal(V2) && size(V2,3) == 1, 'Output should be complex');
|
||||
testcase.verifyLessThan(norm(V1 - V2), 1e-6, 'Too much precision lost in eigenvectors');
|
||||
end
|
||||
|
||||
% complex output from Fourier Transform
|
||||
function complexOutputFFT(testcase)
|
||||
A = randn(10);
|
||||
F1 = fft2(A);
|
||||
F2 = cv.dft(A, cv.DFT_COMPLEX_OUTPUT);
|
||||
testcase.verifyTrue(~isreal(F2) && size(F2,3) == 1, 'Output should be complex');
|
||||
testcase.verifyLessThan(norm(F1 - F2), 1e-6, 'Too much precision lost in eigenvectors');
|
||||
end
|
||||
|
||||
% -------------------------------------------------------------------------
|
||||
% TYPE CASTS
|
||||
% Check that types are correctly cast
|
||||
% -------------------------------------------------------------------------
|
||||
|
||||
% -------------------------------------------------------------------------
|
||||
% PRECISION
|
||||
% Check that basic operations are performed with sufficient precision
|
||||
% -------------------------------------------------------------------------
|
||||
|
||||
% check that summing elements is within reasonable precision
|
||||
function sumElements(testcase)
|
||||
a = randn(5000);
|
||||
b = sum(a(:));
|
||||
c = cv.sum(a);
|
||||
testcase.verifyLessThan(norm(b - c), 1e-8, 'Matrix reduction with insufficient precision');
|
||||
end
|
||||
|
||||
|
||||
% check that adding two matrices is within reasonable precision
|
||||
function addPrecision(testcase)
|
||||
a = randn(50);
|
||||
b = randn(50);
|
||||
c = a+b;
|
||||
d = cv.add(a, b);
|
||||
testcase.verifyLessThan(norm(c - d), 1e-8, 'Matrices are added with insufficient precision');
|
||||
end
|
||||
|
||||
% check that performing gemm is within reasonable precision
|
||||
function gemmPrecision(testcase)
|
||||
a = randn(10, 50);
|
||||
b = randn(50, 10);
|
||||
c = randn(10, 10);
|
||||
alpha = 2.71828;
|
||||
gamma = 1.61803;
|
||||
d = alpha*a*b + gamma*c;
|
||||
e = cv.gemm(a, b, alpha, c, gamma);
|
||||
testcase.verifyLessThan(norm(d - e), 1e-8, 'Matrices are multiplied with insufficient precision');
|
||||
end
|
||||
|
||||
|
||||
% -------------------------------------------------------------------------
|
||||
% MISCELLANEOUS
|
||||
% Miscellaneous tests
|
||||
% -------------------------------------------------------------------------
|
||||
|
||||
% check that cv::waitKey waits for at least specified time
|
||||
function waitKey(testcase)
|
||||
tic();
|
||||
cv.waitKey(500);
|
||||
elapsed = toc();
|
||||
testcase.verifyGreaterThan(elapsed, 0.5, 'Elapsed time should be at least 0.5 seconds');
|
||||
end
|
||||
|
||||
% check that highgui window can be created and destroyed
|
||||
function createAndDestroyWindow(testcase)
|
||||
try
|
||||
cv.namedWindow('test window');
|
||||
catch
|
||||
testcase.verifyFail('could not create window');
|
||||
end
|
||||
|
||||
try
|
||||
cv.destroyWindow('test window');
|
||||
catch
|
||||
testcase.verifyFail('could not destroy window');
|
||||
end
|
||||
testcase.verifyTrue(true);
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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(-1, "OpenCV exception thrown", __func__, __FILE__, __LINE__);
|
||||
} catch(const cv::Exception& e) {
|
||||
mexErrMsgTxt(e.what());
|
||||
} catch(...) {
|
||||
mexErrMsgTxt("Incorrect exception caught!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
function help()
|
||||
%CV.HELP display help information for the OpenCV Toolbox
|
||||
%
|
||||
% Calling:
|
||||
% >> cv.help();
|
||||
%
|
||||
% is equivalent to calling:
|
||||
% >> help cv;
|
||||
%
|
||||
% It displays high-level usage information about the OpenCV toolbox
|
||||
% along with resources to find out more information.
|
||||
%
|
||||
% See also: cv.buildInformation
|
||||
help('cv');
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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(const std::exception& e) {
|
||||
mexErrMsgTxt(e.what());
|
||||
} catch(...) {
|
||||
mexErrMsgTxt("Incorrect exception caught!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* file: rand.cpp
|
||||
* author: A trusty code generator
|
||||
* date: Wed, 19 Jun 2013 11:15:15
|
||||
*
|
||||
* This file was autogenerated, do not modify.
|
||||
* See LICENCE for full modification and redistribution details.
|
||||
* Copyright 2013 The OpenCV Foundation
|
||||
*/
|
||||
#include "mex.h"
|
||||
#include <vector>
|
||||
|
||||
/*
|
||||
* rand
|
||||
* 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 {
|
||||
rand();
|
||||
} catch(...) {
|
||||
mexErrMsgTxt("Uncaught exception occurred in rand");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* a rather innocuous-looking function which is actually
|
||||
* part of <cstdlib>, so we can be reasonably sure its
|
||||
* definition will be found
|
||||
*/
|
||||
#ifndef __OPENCV_MATLAB_TEST_GENERATOR_HPP_
|
||||
#define __OPENCV_MATLAB_TEST_GENERATOR_HPP_
|
||||
|
||||
namespace cv {
|
||||
|
||||
CV_EXPORTS_W int rand( );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
% add the opencv bindings folder
|
||||
addpath ..
|
||||
|
||||
%setup the tests
|
||||
opencv_tests = OpenCVTest();
|
||||
|
||||
%run the tests
|
||||
result = run(opencv_tests);
|
||||
|
||||
% shutdown
|
||||
exit();
|
||||
Reference in New Issue
Block a user