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
fb292b1b
Commit
fb292b1b
authored
Apr 25, 2012
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added PSNR function to imgproc; refactored highgui positioning test (which still fails)
parent
bd49b9b8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
37 deletions
+52
-37
test_precomp.hpp
modules/highgui/test/test_precomp.hpp
+13
-1
test_video_io.cpp
modules/highgui/test/test_video_io.cpp
+27
-36
test_video_pos.cpp
modules/highgui/test/test_video_pos.cpp
+0
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
+3
-0
utils.cpp
modules/imgproc/src/utils.cpp
+9
-0
No files found.
modules/highgui/test/test_precomp.hpp
View file @
fb292b1b
...
...
@@ -61,7 +61,19 @@ namespace cvtest
{
string
fourccToString
(
int
fourcc
);
struct
VideoFormat
{
VideoFormat
()
{
fourcc
=
-
1
;
}
VideoFormat
(
const
string
&
_ext
,
int
_fourcc
)
:
ext
(
_ext
),
fourcc
(
_fourcc
)
{}
bool
empty
()
const
{
return
ext
.
empty
();
}
string
ext
;
int
fourcc
;
};
extern
const
VideoFormat
g_specific_fmt_list
[];
}
#endif
modules/highgui/test/test_video_io.cpp
View file @
fb292b1b
...
...
@@ -46,38 +46,33 @@
using
namespace
cv
;
using
namespace
std
;
string
cvtest
::
fourccToString
(
int
fourcc
)
namespace
cvtest
{
return
format
(
"%c%c%c%c"
,
fourcc
&
255
,
(
fourcc
>>
8
)
&
255
,
(
fourcc
>>
16
)
&
255
,
(
fourcc
>>
24
)
&
255
);
}
str
uct
VideoFmt
str
ing
fourccToString
(
int
fourcc
)
{
VideoFmt
()
{
fourcc
=
-
1
;
}
VideoFmt
(
const
string
&
_ext
,
int
_fourcc
)
:
ext
(
_ext
),
fourcc
(
_fourcc
)
{}
bool
empty
()
const
{
return
ext
.
empty
();
}
return
format
(
"%c%c%c%c"
,
fourcc
&
255
,
(
fourcc
>>
8
)
&
255
,
(
fourcc
>>
16
)
&
255
,
(
fourcc
>>
24
)
&
255
);
}
string
ext
;
int
fourcc
;
};
static
const
VideoFmt
specific_fmt_list
[]
=
const
VideoFormat
g_specific_fmt_list
[]
=
{
VideoF
m
t
(
"avi"
,
CV_FOURCC
(
'm'
,
'p'
,
'e'
,
'g'
)),
VideoF
m
t
(
"avi"
,
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
)),
VideoF
m
t
(
"avi"
,
CV_FOURCC
(
'I'
,
'Y'
,
'U'
,
'V'
)),
VideoF
m
t
(
"mkv"
,
CV_FOURCC
(
'X'
,
'V'
,
'I'
,
'D'
)),
VideoF
m
t
(
"mov"
,
CV_FOURCC
(
'm'
,
'p'
,
'4'
,
'v'
)),
VideoF
m
t
()
VideoF
orma
t
(
"avi"
,
CV_FOURCC
(
'm'
,
'p'
,
'e'
,
'g'
)),
VideoF
orma
t
(
"avi"
,
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
)),
VideoF
orma
t
(
"avi"
,
CV_FOURCC
(
'I'
,
'Y'
,
'U'
,
'V'
)),
VideoF
orma
t
(
"mkv"
,
CV_FOURCC
(
'X'
,
'V'
,
'I'
,
'D'
)),
VideoF
orma
t
(
"mov"
,
CV_FOURCC
(
'm'
,
'p'
,
'4'
,
'v'
)),
VideoF
orma
t
()
};
}
class
CV_HighGuiTest
:
public
cvtest
::
BaseTest
{
protected
:
void
ImageTest
(
const
string
&
dir
);
void
VideoTest
(
const
string
&
dir
,
const
VideoFm
t
&
fmt
);
void
VideoTest
(
const
string
&
dir
,
const
cvtest
::
VideoForma
t
&
fmt
);
void
SpecificImageTest
(
const
string
&
dir
);
void
SpecificVideoTest
(
const
string
&
dir
,
const
VideoFm
t
&
fmt
);
void
SpecificVideoTest
(
const
string
&
dir
,
const
cvtest
::
VideoForma
t
&
fmt
);
CV_HighGuiTest
()
{}
~
CV_HighGuiTest
()
{}
...
...
@@ -116,16 +111,6 @@ public:
void
run
(
int
);
};
double
PSNR
(
const
Mat
&
m1
,
const
Mat
&
m2
)
{
Mat
tmp
;
absdiff
(
m1
.
reshape
(
1
),
m2
.
reshape
(
1
),
tmp
);
multiply
(
tmp
,
tmp
,
tmp
);
double
MSE
=
1.0
/
(
tmp
.
cols
*
tmp
.
rows
)
*
sum
(
tmp
)[
0
];
return
20
*
log10
(
255.0
/
sqrt
(
MSE
));
}
void
CV_HighGuiTest
::
ImageTest
(
const
string
&
dir
)
{
...
...
@@ -233,7 +218,7 @@ void CV_HighGuiTest::ImageTest(const string& dir)
}
void
CV_HighGuiTest
::
VideoTest
(
const
string
&
dir
,
const
VideoFm
t
&
fmt
)
void
CV_HighGuiTest
::
VideoTest
(
const
string
&
dir
,
const
cvtest
::
VideoForma
t
&
fmt
)
{
string
src_file
=
dir
+
"../cv/shared/video_for_test.avi"
;
string
tmp_name
=
format
(
"video.%s"
,
fmt
.
ext
.
c_str
());
...
...
@@ -397,7 +382,7 @@ void CV_HighGuiTest::SpecificImageTest(const string& dir)
}
void
CV_HighGuiTest
::
SpecificVideoTest
(
const
string
&
dir
,
const
VideoFm
t
&
fmt
)
void
CV_HighGuiTest
::
SpecificVideoTest
(
const
string
&
dir
,
const
cvtest
::
VideoForma
t
&
fmt
)
{
string
ext
=
fmt
.
ext
;
int
fourcc
=
fmt
.
fourcc
;
...
...
@@ -505,17 +490,23 @@ void CV_SpecificImageTest::run(int)
void
CV_VideoTest
::
run
(
int
)
{
for
(
int
i
=
0
;
!
specific_fmt_list
[
i
].
empty
()
;
++
i
)
for
(
int
i
=
0
;
;
++
i
)
{
VideoTest
(
ts
->
get_data_path
(),
specific_fmt_list
[
i
]);
const
cvtest
::
VideoFormat
&
fmt
=
cvtest
::
g_specific_fmt_list
[
i
];
if
(
fmt
.
empty
()
)
break
;
VideoTest
(
ts
->
get_data_path
(),
fmt
);
}
}
void
CV_SpecificVideoTest
::
run
(
int
)
{
for
(
int
i
=
0
;
!
specific_fmt_list
[
i
].
empty
()
;
++
i
)
for
(
int
i
=
0
;
;
++
i
)
{
SpecificVideoTest
(
ts
->
get_data_path
(),
specific_fmt_list
[
i
]);
const
cvtest
::
VideoFormat
&
fmt
=
cvtest
::
g_specific_fmt_list
[
i
];
if
(
fmt
.
empty
()
)
break
;
SpecificVideoTest
(
ts
->
get_data_path
(),
fmt
);
}
}
...
...
modules/highgui/test/test_video_pos.cpp
View file @
fb292b1b
This diff is collapsed.
Click to expand it.
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
View file @
fb292b1b
...
...
@@ -597,6 +597,9 @@ CV_EXPORTS_W void accumulateProduct( InputArray src1, InputArray src2,
CV_EXPORTS_W
void
accumulateWeighted
(
InputArray
src
,
InputOutputArray
dst
,
double
alpha
,
InputArray
mask
=
noArray
()
);
//! computes PSNR image/video quality metric
CV_EXPORTS_W
double
PSNR
(
InputArray
src1
,
InputArray
src2
);
CV_EXPORTS_W
Point2d
phaseCorrelate
(
InputArray
src1
,
InputArray
src2
,
InputArray
window
=
noArray
());
CV_EXPORTS_W
void
createHanningWindow
(
OutputArray
dst
,
Size
winSize
,
int
type
);
...
...
modules/imgproc/src/utils.cpp
View file @
fb292b1b
...
...
@@ -245,6 +245,15 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
}
double
cv
::
PSNR
(
InputArray
_src1
,
InputArray
_src2
)
{
Mat
src1
=
_src1
.
getMat
(),
src2
=
_src2
.
getMat
();
CV_Assert
(
src1
.
depth
()
==
CV_8U
);
double
diff
=
std
::
sqrt
(
norm
(
src1
,
src2
,
NORM_L2SQR
)
/
(
src1
.
total
()
*
src1
.
channels
()));
return
20
*
log10
(
255.
/
(
diff
+
DBL_EPSILON
));
}
CV_IMPL
void
cvCopyMakeBorder
(
const
CvArr
*
srcarr
,
CvArr
*
dstarr
,
CvPoint
offset
,
int
borderType
,
CvScalar
value
)
...
...
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