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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
192 additions
and
230 deletions
+192
-230
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
+140
-193
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
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
...
...
@@ -49,170 +49,117 @@ using namespace std;
class
CV_PositioningTest
:
public
cvtest
::
BaseTest
{
public
:
void
CreateTestVideo
(
const
string
&
format
,
int
codec
,
int
framecount
=
125
);
void
run
(
int
);
};
void
CV_PositioningTest
::
CreateTestVideo
(
const
string
&
format
,
int
codec
,
int
framecount
)
{
stringstream
s
;
s
<<
codec
;
//if( format == "mov" && codec == CV_FOURCC('m', 'p', 'e', 'g')
// putchar('$');
cv
::
VideoWriter
writer
(
"test_video_"
+
s
.
str
()
+
"."
+
format
,
codec
,
25
,
cv
::
Size
(
640
,
480
),
false
);
for
(
int
i
=
0
;
i
<
framecount
;
++
i
)
{
cv
::
Mat
mat
(
480
,
640
,
CV_8UC1
);
size_t
n
=
8
,
tmp
=
i
;
vector
<
char
>
tmp_code
;
tmp_code
.
clear
();
while
(
tmp
>
1
)
{
tmp_code
.
push_back
(
tmp
%
2
);
tmp
/=
2
;
}
tmp_code
.
push_back
(
tmp
);
vector
<
char
>
i_code
;
for
(
size_t
j
=
0
;
j
<
n
;
++
j
)
{
char
val
=
j
<
n
-
tmp_code
.
size
()
?
0
:
tmp_code
.
at
(
n
-
1
-
j
);
i_code
.
push_back
(
val
);
}
const
size_t
w
=
480
/
n
;
for
(
size_t
j
=
0
;
j
<
n
;
++
j
)
{
cv
::
Scalar
color
=
i_code
[
j
]
?
255
:
0
;
rectangle
(
mat
,
Rect
(
0
,
w
*
j
,
640
,
w
),
color
,
-
1
);
}
writer
<<
mat
;
}
}
void
CV_PositioningTest
::
run
(
int
)
{
const
string
format
[]
=
{
"avi"
,
"mov"
,
"mp4"
,
"mpg"
,
"wmv"
,
"3gp"
};
const
char
codec
[][
4
]
=
{
{
'X'
,
'V'
,
'I'
,
'D'
},
{
'm'
,
'p'
,
'e'
,
'g'
},
{
'M'
,
'J'
,
'P'
,
'G'
}
};
size_t
n_format
=
sizeof
(
format
)
/
sizeof
(
format
[
0
]),
n_codec
=
sizeof
(
codec
)
/
sizeof
(
codec
[
0
]);
int
n_frames
=
256
;
for
(
size_t
i
=
0
;
i
<
n_format
;
++
i
)
for
(
size_t
j
=
0
;
j
<
n_codec
;
++
j
)
CV_PositioningTest
()
{
CreateTestVideo
(
format
[
i
],
CV_FOURCC
(
codec
[
j
][
0
],
codec
[
j
][
1
],
codec
[
j
][
2
],
codec
[
j
][
3
]),
n_frames
);
stringstream
s
;
s
<<
CV_FOURCC
(
codec
[
j
][
0
],
codec
[
j
][
1
],
codec
[
j
][
2
],
codec
[
j
][
3
]);
//codec_bmp_tags[j].tag;
const
string
file_path
=
"test_video_"
+
s
.
str
()
+
"."
+
format
[
i
];
bool
error
=
false
;
int
failed
=
0
;
cv
::
VideoCapture
cap
(
file_path
);
if
(
!
cap
.
isOpened
())
{
ts
->
printf
(
ts
->
LOG
,
"
\n\n
File: %s
\n
"
,
file_path
.
c_str
());
ts
->
printf
(
ts
->
LOG
,
"
\n
Video codec: %s
\n
"
,
string
(
&
codec
[
j
][
0
],
4
).
c_str
());
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot read video file."
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_TEST_DATA
);
error
=
true
;
}
cap
.
set
(
CV_CAP_PROP_POS_FRAMES
,
0
);
int
N
=
cap
.
get
(
CV_CAP_PROP_FRAME_COUNT
);
if
(
N
!=
n_frames
)
{
if
(
!
error
)
framesize
=
Size
(
640
,
480
);
}
Mat
drawFrame
(
int
i
)
{
Mat
mat
=
Mat
::
zeros
(
framesize
,
CV_8UC3
);
mat
=
Scalar
(
fabs
(
cos
(
i
*
0.08
)
*
255
),
fabs
(
sin
(
i
*
0.05
)
*
255
),
i
);
putText
(
mat
,
format
(
"%03d"
,
i
),
Point
(
10
,
350
),
0
,
10
,
Scalar
(
128
,
255
,
255
),
15
);
return
mat
;
}
string
getFilename
(
const
cvtest
::
VideoFormat
&
fmt
)
{
return
format
(
"test_video_%s.%s"
,
cvtest
::
fourccToString
(
fmt
.
fourcc
).
c_str
(),
fmt
.
ext
.
c_str
()
);
}
bool
CreateTestVideo
(
const
cvtest
::
VideoFormat
&
fmt
,
int
framecount
)
{
string
filename
=
getFilename
(
fmt
);
VideoWriter
writer
(
filename
,
fmt
.
fourcc
,
25
,
framesize
,
true
);
if
(
!
writer
.
isOpened
()
)
return
false
;
for
(
int
i
=
0
;
i
<
framecount
;
++
i
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n\n
File: %s
\n
"
,
file_path
.
c_str
());
ts
->
printf
(
ts
->
LOG
,
"
\n
Video codec: %s
\n
"
,
string
(
&
codec
[
j
][
0
],
4
).
c_str
());
error
=
true
;
Mat
img
=
drawFrame
(
i
);
writer
<<
img
;
}
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: returned frame count in clip is incorrect.
\n
"
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
}
vector
<
int
>
idx
;
RNG
rng
(
N
);
idx
.
clear
();
for
(
int
k
=
0
;
k
<
N
-
1
;
k
++
)
idx
.
push_back
(
rng
.
uniform
(
0
,
N
));
idx
.
push_back
(
N
-
1
);
std
::
swap
(
idx
.
at
(
rng
.
uniform
(
0
,
N
-
1
)),
idx
.
at
(
N
-
1
));
for
(
int
k
=
0
;
k
<
N
;
++
k
)
{
cap
.
set
(
CV_CAP_PROP_POS_FRAMES
,
(
double
)
idx
[
k
]);
cv
::
Mat
img
;
cap
.
retrieve
(
img
);
return
true
;
}
if
(
img
.
empty
())
void
run
(
int
)
{
int
n_frames
=
100
;
for
(
int
testcase
=
0
;
;
testcase
++
)
{
if
(
!
error
)
const
cvtest
::
VideoFormat
&
fmt
=
cvtest
::
g_specific_fmt_list
[
testcase
];
if
(
fmt
.
empty
()
)
break
;
string
filename
=
getFilename
(
fmt
);
ts
->
printf
(
ts
->
LOG
,
"
\n\n
File: %s
\n
"
,
filename
.
c_str
());
if
(
!
CreateTestVideo
(
fmt
,
n_frames
)
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n
\n
File: %s
\n
"
,
file_path
.
c_str
()
);
ts
->
printf
(
ts
->
LOG
,
"
\n
Video codec: %s
\n
"
,
string
(
&
codec
[
j
][
0
],
4
).
c_str
()
);
error
=
true
;
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot create video file"
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
return
;
}
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot read a frame in position %d.
\n
"
,
idx
[
k
]);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
}
const
double
thresh
=
100
;
const
size_t
n
=
8
,
w
=
img
.
rows
/
n
;
int
index
=
0
,
deg
=
n
-
1
;
for
(
size_t
l
=
0
;
l
<
n
;
++
l
)
{
cv
::
Mat
mat
=
img
.
rowRange
(
w
*
l
,
w
*
(
l
+
1
)
-
1
);
Scalar
mat_mean
=
cv
::
mean
(
mat
);
if
(
mat_mean
[
0
]
>
thresh
)
index
+=
(
int
)
std
::
pow
(
2.0
,
1.0
*
deg
);
deg
--
;
}
if
(
index
!=
idx
[
k
])
{
if
(
!
error
)
VideoCapture
cap
(
filename
);
if
(
!
cap
.
isOpened
())
{
ts
->
printf
(
ts
->
LOG
,
"
\n\n
File: %s
\n
"
,
file_path
.
c_str
());
ts
->
printf
(
ts
->
LOG
,
"
\n
Video codec: %s
\n\n
"
,
string
(
&
codec
[
j
][
0
],
4
).
c_str
());
error
=
true
;
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot read video file."
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_TEST_DATA
);
return
;
}
int
N0
=
cap
.
get
(
CV_CAP_PROP_FRAME_COUNT
);
cap
.
set
(
CV_CAP_PROP_POS_FRAMES
,
0
);
int
N
=
cap
.
get
(
CV_CAP_PROP_FRAME_COUNT
);
if
(
N
!=
n_frames
||
N
!=
N0
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: returned frame count (N0=%d, N=%d) is different from the reference number %d
\n
"
,
N0
,
N
,
n_frames
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
return
;
}
for
(
int
k
=
0
;
k
<
N
;
++
k
)
{
int
idx
=
theRNG
().
uniform
(
0
,
N
);
if
(
!
cap
.
set
(
CV_CAP_PROP_POS_FRAMES
,
idx
)
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot seek to frame %d.
\n
"
,
idx
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
return
;
}
Mat
img
;
cap
>>
img
;
if
(
img
.
empty
())
{
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot read a frame at position %d.
\n
"
,
idx
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
return
;
}
Mat
img0
=
drawFrame
(
idx
);
double
err
=
PSNR
(
img
,
img0
);
if
(
err
<
20
)
{
ts
->
printf
(
ts
->
LOG
,
"The frame read after positioning to %d is incorrect (PSNR=%g)
\n
"
,
idx
,
err
);
ts
->
printf
(
ts
->
LOG
,
"Saving both frames ...
\n
"
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
imwrite
(
"opencv_test_highgui_postest_actual.png"
,
img
);
imwrite
(
"opencv_test_highgui_postest_expected.png"
,
img0
);
return
;
}
}
ts
->
printf
(
ts
->
LOG
,
"Required position: %d Returned position: %d
\n
"
,
idx
[
k
],
index
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
failed
++
;
}
}
if
(
!
error
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n\n
File: %s
\n
"
,
file_path
.
c_str
());
ts
->
printf
(
ts
->
LOG
,
"
\n
Video codec: %s
\n
"
,
string
(
&
codec
[
j
][
0
],
4
).
c_str
());
}
const
string
status
=
failed
?
"FAILED"
:
"OK"
;
ts
->
printf
(
ts
->
LOG
,
"
\n
Successfull iterations: %d(%d%%) Failed iterations: %d(%d%%) %s
\n
"
,
N
-
failed
,
(
N
-
failed
)
*
100
/
N
,
failed
,
failed
*
100
/
N
,
status
.
c_str
());
if
(
i
<
n_format
-
1
||
j
<
n_codec
-
1
)
ts
->
printf
(
ts
->
LOG
,
"
\n
----------"
);
}
}
Size
framesize
;
};
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT
TEST
(
Highgui_Positioning
,
regression
)
{
CV_PositioningTest
test
;
test
.
safe_run
();
}
...
...
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