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
4a63b3dd
Commit
4a63b3dd
authored
Apr 08, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cv2cvtest part2
parent
5600bc54
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
39 deletions
+49
-39
test_ffmpeg.cpp
modules/highgui/test/test_ffmpeg.cpp
+1
-1
test_video_io.cpp
modules/highgui/test/test_video_io.cpp
+6
-6
test_video_pos.cpp
modules/highgui/test/test_video_pos.cpp
+1
-1
test_stereomatching.cpp
modules/legacy/test/test_stereomatching.cpp
+1
-1
test_denoise_tvl1.cpp
modules/optim/test/test_denoise_tvl1.cpp
+19
-16
test_denoising.cpp
modules/photo/test/test_denoising.cpp
+4
-4
test_inpaint.cpp
modules/photo/test/test_inpaint.cpp
+4
-4
test_blenders.cpp
modules/stitching/test/test_blenders.cpp
+1
-1
ts.hpp
modules/ts/include/opencv2/ts.hpp
+1
-0
ts_func.cpp
modules/ts/src/ts_func.cpp
+6
-0
test_estimaterigid.cpp
modules/video/test/test_estimaterigid.cpp
+5
-5
No files found.
modules/highgui/test/test_ffmpeg.cpp
View file @
4a63b3dd
...
...
@@ -329,7 +329,7 @@ public:
EXPECT_EQ
(
reference
.
depth
(),
actual
.
depth
());
EXPECT_EQ
(
reference
.
channels
(),
actual
.
channels
());
double
psnr
=
PSNR
(
actual
,
reference
);
double
psnr
=
cvtest
::
PSNR
(
actual
,
reference
);
if
(
psnr
<
eps
)
{
#define SUM cvtest::TS::SUMMARY
...
...
modules/highgui/test/test_video_io.cpp
View file @
4a63b3dd
...
...
@@ -198,7 +198,7 @@ void CV_HighGuiTest::ImageTest(const string& dir)
}
const
double
thresDbell
=
20
;
double
psnr
=
PSNR
(
loaded
,
image
);
double
psnr
=
cvtest
::
PSNR
(
loaded
,
image
);
if
(
psnr
<
thresDbell
)
{
ts
->
printf
(
ts
->
LOG
,
"Reading image from file: too big difference (=%g) with fmt=%s
\n
"
,
psnr
,
ext
.
c_str
());
...
...
@@ -235,7 +235,7 @@ void CV_HighGuiTest::ImageTest(const string& dir)
continue
;
}
psnr
=
PSNR
(
buf_loaded
,
image
);
psnr
=
cvtest
::
PSNR
(
buf_loaded
,
image
);
if
(
psnr
<
thresDbell
)
{
...
...
@@ -316,7 +316,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
Mat
img
=
frames
[
i
];
Mat
img1
=
cv
::
cvarrToMat
(
ipl1
);
double
psnr
=
PSNR
(
img1
,
img
);
double
psnr
=
cvtest
::
PSNR
(
img1
,
img
);
if
(
psnr
<
thresDbell
)
{
ts
->
printf
(
ts
->
LOG
,
"Too low frame %d psnr = %gdb
\n
"
,
i
,
psnr
);
...
...
@@ -371,7 +371,7 @@ void CV_HighGuiTest::SpecificImageTest(const string& dir)
}
const
double
thresDbell
=
20
;
double
psnr
=
PSNR
(
loaded
,
image
);
double
psnr
=
cvtest
::
PSNR
(
loaded
,
image
);
if
(
psnr
<
thresDbell
)
{
ts
->
printf
(
ts
->
LOG
,
"Reading image from file: too big difference (=%g) with fmt=bmp
\n
"
,
psnr
);
...
...
@@ -408,7 +408,7 @@ void CV_HighGuiTest::SpecificImageTest(const string& dir)
continue
;
}
psnr
=
PSNR
(
buf_loaded
,
image
);
psnr
=
cvtest
::
PSNR
(
buf_loaded
,
image
);
if
(
psnr
<
thresDbell
)
{
...
...
@@ -521,7 +521,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
Mat
img
=
images
[
i
];
const
double
thresDbell
=
40
;
double
psnr
=
PSNR
(
img
,
frame
);
double
psnr
=
cvtest
::
PSNR
(
img
,
frame
);
if
(
psnr
>
thresDbell
)
{
...
...
modules/highgui/test/test_video_pos.cpp
View file @
4a63b3dd
...
...
@@ -160,7 +160,7 @@ public:
return
;
}
double
err
=
PSNR
(
img
,
img0
);
double
err
=
cvtest
::
PSNR
(
img
,
img0
);
if
(
err
<
20
)
{
...
...
modules/legacy/test/test_stereomatching.cpp
View file @
4a63b3dd
...
...
@@ -278,7 +278,7 @@ float dispRMS( const Mat& computedDisp, const Mat& groundTruthDisp, const Mat& m
checkTypeAndSizeOfMask
(
mask
,
sz
);
pointsCount
=
countNonZero
(
mask
);
}
return
1.
f
/
sqrt
((
float
)
pointsCount
)
*
(
float
)
norm
(
computedDisp
,
groundTruthDisp
,
NORM_L2
,
mask
);
return
1.
f
/
sqrt
((
float
)
pointsCount
)
*
(
float
)
cvtest
::
norm
(
computedDisp
,
groundTruthDisp
,
NORM_L2
,
mask
);
}
/*
...
...
modules/optim/test/test_denoise_tvl1.cpp
View file @
4a63b3dd
...
...
@@ -41,7 +41,8 @@
#include "test_precomp.hpp"
#include "opencv2/highgui.hpp"
void
make_noisy
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
noisy
,
double
sigma
,
double
pepper_salt_ratio
,
cv
::
RNG
&
rng
){
void
make_noisy
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
noisy
,
double
sigma
,
double
pepper_salt_ratio
,
cv
::
RNG
&
rng
)
{
noisy
.
create
(
img
.
size
(),
img
.
type
());
cv
::
Mat
noise
(
img
.
size
(),
img
.
type
()),
mask
(
img
.
size
(),
CV_8U
);
rng
.
fill
(
noise
,
cv
::
RNG
::
NORMAL
,
128.0
,
sigma
);
...
...
@@ -54,34 +55,36 @@ void make_noisy(const cv::Mat& img, cv::Mat& noisy, double sigma, double pepper_
noise
.
setTo
(
128
,
mask
);
cv
::
addWeighted
(
noisy
,
1
,
noise
,
1
,
-
128
,
noisy
);
}
void
make_spotty
(
cv
::
Mat
&
img
,
cv
::
RNG
&
rng
,
int
r
=
3
,
int
n
=
1000
){
for
(
int
i
=
0
;
i
<
n
;
i
++
){
void
make_spotty
(
cv
::
Mat
&
img
,
cv
::
RNG
&
rng
,
int
r
=
3
,
int
n
=
1000
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
int
x
=
rng
(
img
.
cols
-
r
),
y
=
rng
(
img
.
rows
-
r
);
if
(
rng
(
2
)
==
0
)
{
if
(
rng
(
2
)
==
0
)
img
(
cv
::
Range
(
y
,
y
+
r
),
cv
::
Range
(
x
,
x
+
r
))
=
(
uchar
)
0
;
}
else
{
else
img
(
cv
::
Range
(
y
,
y
+
r
),
cv
::
Range
(
x
,
x
+
r
))
=
(
uchar
)
255
;
}
}
}
bool
validate_pixel
(
const
cv
::
Mat
&
image
,
int
x
,
int
y
,
uchar
val
){
bool
validate_pixel
(
const
cv
::
Mat
&
image
,
int
x
,
int
y
,
uchar
val
)
{
printf
(
"test: image(%d,%d)=%d vs %d - %s
\n
"
,
x
,
y
,(
int
)
image
.
at
<
uchar
>
(
x
,
y
),
val
,(
val
==
image
.
at
<
uchar
>
(
x
,
y
))
?
"true"
:
"false"
);
return
(
image
.
at
<
uchar
>
(
x
,
y
)
==
val
);
}
TEST
(
Optim_denoise_tvl1
,
regression_basic
){
TEST
(
Optim_denoise_tvl1
,
regression_basic
)
{
cv
::
RNG
rng
(
42
);
cv
::
Mat
img
=
cv
::
imread
(
"lena.jpg"
,
0
),
noisy
,
res
;
if
(
img
.
rows
!=
512
||
img
.
cols
!=
512
){
printf
(
"
\t
please, put lena.jpg from samples/c in the current folder
\n
"
);
printf
(
"
\t
now, the test will fail...
\n
"
);
ASSERT_TRUE
(
false
);
}
cv
::
Mat
img
=
cv
::
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"shared/lena.png"
,
0
),
noisy
,
res
;
ASSERT_FALSE
(
img
.
empty
())
<<
"Error: can't open 'lena.png'"
;
const
int
obs_num
=
5
;
std
::
vector
<
cv
::
Mat
>
images
(
obs_num
,
cv
::
Mat
());
for
(
int
i
=
0
;
i
<
(
int
)
images
.
size
();
i
++
){
std
::
vector
<
cv
::
Mat
>
images
(
obs_num
,
cv
::
Mat
());
for
(
int
i
=
0
;
i
<
(
int
)
images
.
size
();
i
++
)
{
make_noisy
(
img
,
images
[
i
],
20
,
0.02
,
rng
);
//make_spotty(images[i],rng);
}
...
...
modules/photo/test/test_denoising.cpp
View file @
4a63b3dd
...
...
@@ -73,7 +73,7 @@ TEST(Photo_DenoisingGrayscale, regression)
DUMP
(
result
,
expected_path
+
".res.png"
);
ASSERT_EQ
(
0
,
norm
(
result
!=
expected
));
ASSERT_EQ
(
0
,
cvtest
::
norm
(
result
,
expected
,
NORM_L2
));
}
TEST
(
Photo_DenoisingColored
,
regression
)
...
...
@@ -93,7 +93,7 @@ TEST(Photo_DenoisingColored, regression)
DUMP
(
result
,
expected_path
+
".res.png"
);
ASSERT_EQ
(
0
,
norm
(
result
!=
expected
));
ASSERT_EQ
(
0
,
cvtest
::
norm
(
result
,
expected
,
NORM_L2
));
}
TEST
(
Photo_DenoisingGrayscaleMulti
,
regression
)
...
...
@@ -118,7 +118,7 @@ TEST(Photo_DenoisingGrayscaleMulti, regression)
DUMP
(
result
,
expected_path
+
".res.png"
);
ASSERT_EQ
(
0
,
norm
(
result
!=
expected
));
ASSERT_EQ
(
0
,
cvtest
::
norm
(
result
,
expected
,
NORM_L2
));
}
TEST
(
Photo_DenoisingColoredMulti
,
regression
)
...
...
@@ -143,7 +143,7 @@ TEST(Photo_DenoisingColoredMulti, regression)
DUMP
(
result
,
expected_path
+
".res.png"
);
ASSERT_EQ
(
0
,
norm
(
result
!=
expected
));
ASSERT_EQ
(
0
,
cvtest
::
norm
(
result
,
expected
,
NORM_L2
));
}
TEST
(
Photo_White
,
issue_2646
)
...
...
modules/photo/test/test_inpaint.cpp
View file @
4a63b3dd
...
...
@@ -91,8 +91,8 @@ void CV_InpaintTest::run( int )
absdiff
(
orig
,
res1
,
diff1
);
absdiff
(
orig
,
res2
,
diff2
);
double
n1
=
norm
(
diff1
.
reshape
(
1
),
NORM_INF
,
inv_mask
.
reshape
(
1
));
double
n2
=
norm
(
diff2
.
reshape
(
1
),
NORM_INF
,
inv_mask
.
reshape
(
1
));
double
n1
=
cvtest
::
norm
(
diff1
.
reshape
(
1
),
NORM_INF
,
inv_mask
.
reshape
(
1
));
double
n2
=
cvtest
::
norm
(
diff2
.
reshape
(
1
),
NORM_INF
,
inv_mask
.
reshape
(
1
));
if
(
n1
!=
0
||
n2
!=
0
)
{
...
...
@@ -103,8 +103,8 @@ void CV_InpaintTest::run( int )
absdiff
(
exp1
,
res1
,
diff1
);
absdiff
(
exp2
,
res2
,
diff2
);
n1
=
norm
(
diff1
.
reshape
(
1
),
NORM_INF
,
mask
.
reshape
(
1
));
n2
=
norm
(
diff2
.
reshape
(
1
),
NORM_INF
,
mask
.
reshape
(
1
));
n1
=
cvtest
::
norm
(
diff1
.
reshape
(
1
),
NORM_INF
,
mask
.
reshape
(
1
));
n2
=
cvtest
::
norm
(
diff2
.
reshape
(
1
),
NORM_INF
,
mask
.
reshape
(
1
));
const
int
jpeg_thres
=
3
;
if
(
n1
>
jpeg_thres
||
n2
>
jpeg_thres
)
...
...
modules/stitching/test/test_blenders.cpp
View file @
4a63b3dd
...
...
@@ -73,6 +73,6 @@ TEST(MultiBandBlender, CanBlendTwoImages)
Mat
result
;
result_s
.
convertTo
(
result
,
CV_8U
);
Mat
expected
=
imread
(
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"stitching/baboon_lena.png"
);
double
rmsErr
=
norm
(
expected
,
result
,
NORM_L2
)
/
sqrt
(
double
(
expected
.
size
().
area
()));
double
rmsErr
=
cvtest
::
norm
(
expected
,
result
,
NORM_L2
)
/
sqrt
(
double
(
expected
.
size
().
area
()));
ASSERT_LT
(
rmsErr
,
1e-3
);
}
modules/ts/include/opencv2/ts.hpp
View file @
4a63b3dd
...
...
@@ -129,6 +129,7 @@ CV_EXPORTS void minMaxLoc(const Mat& src, double* minval, double* maxval,
CV_EXPORTS
double
norm
(
InputArray
src
,
int
normType
,
InputArray
mask
=
noArray
());
CV_EXPORTS
double
norm
(
InputArray
src1
,
InputArray
src2
,
int
normType
,
InputArray
mask
=
noArray
());
CV_EXPORTS
Scalar
mean
(
const
Mat
&
src
,
const
Mat
&
mask
=
Mat
());
CV_EXPORTS
double
PSNR
(
InputArray
src1
,
InputArray
src2
);
CV_EXPORTS
bool
cmpUlps
(
const
Mat
&
data
,
const
Mat
&
refdata
,
int
expMaxDiff
,
double
*
realMaxDiff
,
vector
<
int
>*
idx
);
...
...
modules/ts/src/ts_func.cpp
View file @
4a63b3dd
...
...
@@ -1399,6 +1399,12 @@ double norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask)
return
isRelative
?
result
/
(
cvtest
::
norm
(
src2
,
normType
)
+
DBL_EPSILON
)
:
result
;
}
double
PSNR
(
InputArray
_src1
,
InputArray
_src2
)
{
CV_Assert
(
_src1
.
depth
()
==
CV_8U
);
double
diff
=
std
::
sqrt
(
cvtest
::
norm
(
_src1
,
_src2
,
NORM_L2SQR
)
/
(
_src1
.
total
()
*
_src1
.
channels
()));
return
20
*
log10
(
255.
/
(
diff
+
DBL_EPSILON
));
}
template
<
typename
_Tp
>
static
double
crossCorr_
(
const
_Tp
*
src1
,
const
_Tp
*
src2
,
size_t
total
)
...
...
modules/video/test/test_estimaterigid.cpp
View file @
4a63b3dd
...
...
@@ -109,8 +109,8 @@ bool CV_RigidTransform_Test::testNPoints(int from)
Mat
aff_est
=
estimateRigidTransform
(
fpts
,
tpts
,
true
);
double
thres
=
0.1
*
norm
(
aff
);
double
d
=
norm
(
aff_est
,
aff
,
NORM_L2
);
double
thres
=
0.1
*
cvtest
::
norm
(
aff
,
NORM_L2
);
double
d
=
cvtest
::
norm
(
aff_est
,
aff
,
NORM_L2
);
if
(
d
>
thres
)
{
double
dB
=
0
,
nB
=
0
;
...
...
@@ -120,7 +120,7 @@ bool CV_RigidTransform_Test::testNPoints(int from)
Mat
B
=
A
-
repeat
(
A
.
row
(
0
),
3
,
1
),
Bt
=
B
.
t
();
B
=
Bt
*
B
;
dB
=
cv
::
determinant
(
B
);
nB
=
norm
(
B
);
nB
=
cvtest
::
norm
(
B
,
NORM_L2
);
if
(
fabs
(
dB
)
<
0.01
*
nB
)
continue
;
}
...
...
@@ -154,11 +154,11 @@ bool CV_RigidTransform_Test::testImage()
Mat
aff_est
=
estimateRigidTransform
(
img
,
rotated
,
true
);
const
double
thres
=
0.033
;
if
(
norm
(
aff_est
,
aff
,
NORM_INF
)
>
thres
)
if
(
cvtest
::
norm
(
aff_est
,
aff
,
NORM_INF
)
>
thres
)
{
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_BAD_ACCURACY
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Threshold = %f, norm of difference = %f"
,
thres
,
norm
(
aff_est
,
aff
,
NORM_INF
)
);
cvtest
::
norm
(
aff_est
,
aff
,
NORM_INF
)
);
return
false
;
}
...
...
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