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
9cc949e3
Commit
9cc949e3
authored
Jul 12, 2013
by
hbristow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more test cases
parent
5a34b007
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
OpenCVTest.m
modules/matlab/test/OpenCVTest.m
+82
-0
No files found.
modules/matlab/test/OpenCVTest.m
View file @
9cc949e3
...
...
@@ -4,6 +4,11 @@ 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
...
...
@@ -37,6 +42,11 @@ classdef OpenCVTest < matlab.unittest.TestCase
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
];
...
...
@@ -46,6 +56,61 @@ classdef OpenCVTest < matlab.unittest.TestCase
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
% -------------------------------------------------------------------------
% 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
();
...
...
@@ -53,5 +118,22 @@ classdef OpenCVTest < matlab.unittest.TestCase
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
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