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
d27009c7
Commit
d27009c7
authored
Jun 22, 2017
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8856 from mshabunin:media-tests-upgrade
parents
4eb5242e
87b569d8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
806 additions
and
919 deletions
+806
-919
cvconfig.h.in
cmake/templates/cvconfig.h.in
+20
-0
perf_bgsegm.cpp
modules/cudabgsegm/perf/perf_bgsegm.cpp
+3
-16
test_bgsegm.cpp
modules/cudabgsegm/test/test_bgsegm.cpp
+1
-14
perf_video.cpp
modules/cudacodec/perf/perf_video.cpp
+1
-14
perf_bgsegm.cpp
modules/cudalegacy/perf/perf_bgsegm.cpp
+2
-15
test_grfmt.cpp
modules/imgcodecs/test/test_grfmt.cpp
+0
-0
test_jpeg.cpp
modules/imgcodecs/test/test_jpeg.cpp
+180
-0
test_png.cpp
modules/imgcodecs/test/test_png.cpp
+95
-0
test_precomp.hpp
modules/imgcodecs/test/test_precomp.hpp
+6
-1
test_read_write.cpp
modules/imgcodecs/test/test_read_write.cpp
+122
-0
test_tiff.cpp
modules/imgcodecs/test/test_tiff.cpp
+202
-0
test_webp.cpp
modules/imgcodecs/test/test_webp.cpp
+106
-0
test_precomp.hpp
modules/superres/test/test_precomp.hpp
+0
-13
test_superres.cpp
modules/superres/test/test_superres.cpp
+2
-2
ts_func.cpp
modules/ts/src/ts_func.cpp
+3
-3
perf_bgfg_mog2.cpp
modules/video/perf/opencl/perf_bgfg_mog2.cpp
+3
-17
test_bgfg_mog2.cpp
modules/video/test/ocl/test_bgfg_mog2.cpp
+2
-15
perf_input.cpp
modules/videoio/perf/perf_input.cpp
+15
-18
perf_output.cpp
modules/videoio/perf/perf_output.cpp
+24
-19
perf_precomp.hpp
modules/videoio/perf/perf_precomp.hpp
+0
-29
cap.cpp
modules/videoio/src/cap.cpp
+0
-5
precomp.hpp
modules/videoio/src/precomp.hpp
+0
-1
test_basic_props.cpp
modules/videoio/test/test_basic_props.cpp
+0
-157
test_framecount.cpp
modules/videoio/test/test_framecount.cpp
+0
-114
test_positioning.cpp
modules/videoio/test/test_positioning.cpp
+0
-223
test_precomp.hpp
modules/videoio/test/test_precomp.hpp
+19
-64
test_video_io.cpp
modules/videoio/test/test_video_io.cpp
+0
-0
test_video_pos.cpp
modules/videoio/test/test_video_pos.cpp
+0
-179
No files found.
cmake/templates/cvconfig.h.in
View file @
d27009c7
...
...
@@ -220,6 +220,26 @@
/* OpenVX */
#cmakedefine HAVE_OPENVX
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
/*defined(HAVE_OPENNI) || too specialized */ \
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF)
#define HAVE_VIDEO_INPUT
#endif
#if /*defined(HAVE_XINE) || */\
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF)
#define HAVE_VIDEO_OUTPUT
#endif
#endif // OPENCV_CVCONFIG_H_INCLUDED
modules/cudabgsegm/perf/perf_bgsegm.cpp
View file @
d27009c7
...
...
@@ -46,23 +46,10 @@ using namespace std;
using
namespace
testing
;
using
namespace
perf
;
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32)
/* assume that we have ffmpeg */
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
//////////////////////////////////////////////////////
// MOG
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
DEF_PARAM_TEST
(
Video_Cn_LearningRate
,
string
,
MatCn
,
double
);
...
...
@@ -167,7 +154,7 @@ PERF_TEST_P(Video_Cn_LearningRate, MOG,
//////////////////////////////////////////////////////
// MOG2
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
DEF_PARAM_TEST
(
Video_Cn
,
string
,
int
);
...
...
@@ -324,7 +311,7 @@ PERF_TEST_P(Video_Cn, DISABLED_MOG2,
//////////////////////////////////////////////////////
// MOG2GetBackgroundImage
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
PERF_TEST_P
(
Video_Cn
,
MOG2GetBackgroundImage
,
Combine
(
Values
(
"gpu/video/768x576.avi"
,
"gpu/video/1920x1080.avi"
),
...
...
modules/cudabgsegm/test/test_bgsegm.cpp
View file @
d27009c7
...
...
@@ -46,23 +46,10 @@
using
namespace
cvtest
;
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32)
/* assume that we have ffmpeg */
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
//////////////////////////////////////////////////////
// MOG2
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
namespace
{
...
...
modules/cudacodec/perf/perf_video.cpp
View file @
d27009c7
...
...
@@ -47,25 +47,12 @@ using namespace std;
using
namespace
testing
;
using
namespace
perf
;
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32)
/* assume that we have ffmpeg */
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
DEF_PARAM_TEST_1
(
FileName
,
string
);
//////////////////////////////////////////////////////
// VideoReader
#if defined(HAVE_NVCUVID) &&
BUILD_WITH_VIDEO_INPUT_SUPPORT
#if defined(HAVE_NVCUVID) &&
defined(HAVE_VIDEO_INPUT)
PERF_TEST_P
(
FileName
,
VideoReader
,
Values
(
"gpu/video/768x576.avi"
,
"gpu/video/1920x1080.avi"
))
{
...
...
modules/cudalegacy/perf/perf_bgsegm.cpp
View file @
d27009c7
...
...
@@ -50,23 +50,10 @@ using namespace std;
using
namespace
testing
;
using
namespace
perf
;
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32)
/* assume that we have ffmpeg */
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
//////////////////////////////////////////////////////
// FGDStatModel
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
DEF_PARAM_TEST_1
(
Video
,
string
);
...
...
@@ -136,7 +123,7 @@ PERF_TEST_P(Video, FGDStatModel,
//////////////////////////////////////////////////////
// GMG
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
DEF_PARAM_TEST
(
Video_Cn_MaxFeatures
,
string
,
MatCn
,
int
);
...
...
modules/imgcodecs/test/test_grfmt.cpp
View file @
d27009c7
This diff is collapsed.
Click to expand it.
modules/imgcodecs/test/test_jpeg.cpp
0 → 100644
View file @
d27009c7
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
::
tr1
;
#ifdef HAVE_JPEG
/**
* Test for check whether reading exif orientation tag was processed successfully or not
* The test info is the set of 8 images named testExifRotate_{1 to 8}.jpg
* The test image is the square 10x10 points divided by four sub-squares:
* (R corresponds to Red, G to Green, B to Blue, W to white)
* --------- ---------
* | R | G | | G | R |
* |-------| - (tag 1) |-------| - (tag 2)
* | B | W | | W | B |
* --------- ---------
*
* --------- ---------
* | W | B | | B | W |
* |-------| - (tag 3) |-------| - (tag 4)
* | G | R | | R | G |
* --------- ---------
*
* --------- ---------
* | R | B | | G | W |
* |-------| - (tag 5) |-------| - (tag 6)
* | G | W | | R | B |
* --------- ---------
*
* --------- ---------
* | W | G | | B | R |
* |-------| - (tag 7) |-------| - (tag 8)
* | B | R | | W | G |
* --------- ---------
*
*
* Every image contains exif field with orientation tag (0x112)
* After reading each image the corresponding matrix must be read as
* ---------
* | R | G |
* |-------|
* | B | W |
* ---------
*
*/
typedef
testing
::
TestWithParam
<
string
>
Imgcodecs_Jpeg_Exif
;
TEST_P
(
Imgcodecs_Jpeg_Exif
,
exif_orientation
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filename
=
root
+
GetParam
();
const
int
colorThresholdHigh
=
250
;
const
int
colorThresholdLow
=
5
;
Mat
m_img
=
imread
(
filename
);
ASSERT_FALSE
(
m_img
.
empty
());
Vec3b
vec
;
//Checking the first quadrant (with supposed red)
vec
=
m_img
.
at
<
Vec3b
>
(
2
,
2
);
//some point inside the square
EXPECT_LE
(
vec
.
val
[
0
],
colorThresholdLow
);
EXPECT_LE
(
vec
.
val
[
1
],
colorThresholdLow
);
EXPECT_GE
(
vec
.
val
[
2
],
colorThresholdHigh
);
//Checking the second quadrant (with supposed green)
vec
=
m_img
.
at
<
Vec3b
>
(
2
,
7
);
//some point inside the square
EXPECT_LE
(
vec
.
val
[
0
],
colorThresholdLow
);
EXPECT_GE
(
vec
.
val
[
1
],
colorThresholdHigh
);
EXPECT_LE
(
vec
.
val
[
2
],
colorThresholdLow
);
//Checking the third quadrant (with supposed blue)
vec
=
m_img
.
at
<
Vec3b
>
(
7
,
2
);
//some point inside the square
EXPECT_GE
(
vec
.
val
[
0
],
colorThresholdHigh
);
EXPECT_LE
(
vec
.
val
[
1
],
colorThresholdLow
);
EXPECT_LE
(
vec
.
val
[
2
],
colorThresholdLow
);
}
const
string
exif_files
[]
=
{
"readwrite/testExifOrientation_1.jpg"
,
"readwrite/testExifOrientation_2.jpg"
,
"readwrite/testExifOrientation_3.jpg"
,
"readwrite/testExifOrientation_4.jpg"
,
"readwrite/testExifOrientation_5.jpg"
,
"readwrite/testExifOrientation_6.jpg"
,
"readwrite/testExifOrientation_7.jpg"
,
"readwrite/testExifOrientation_8.jpg"
};
INSTANTIATE_TEST_CASE_P
(
ExifFiles
,
Imgcodecs_Jpeg_Exif
,
testing
::
ValuesIn
(
exif_files
));
//==================================================================================================
TEST
(
Imgcodecs_Jpeg
,
encode_empty
)
{
cv
::
Mat
img
;
std
::
vector
<
uchar
>
jpegImg
;
ASSERT_THROW
(
cv
::
imencode
(
".jpg"
,
img
,
jpegImg
),
cv
::
Exception
);
}
TEST
(
Imgcodecs_Jpeg
,
encode_decode_progressive_jpeg
)
{
cvtest
::
TS
&
ts
=
*
cvtest
::
TS
::
ptr
();
string
input
=
string
(
ts
.
get_data_path
())
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
input
);
ASSERT_FALSE
(
img
.
empty
());
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_JPEG_PROGRESSIVE
);
params
.
push_back
(
1
);
string
output_progressive
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_progressive
,
img
,
params
));
cv
::
Mat
img_jpg_progressive
=
cv
::
imread
(
output_progressive
);
string
output_normal
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_normal
,
img
));
cv
::
Mat
img_jpg_normal
=
cv
::
imread
(
output_normal
);
EXPECT_EQ
(
0
,
cvtest
::
norm
(
img_jpg_progressive
,
img_jpg_normal
,
NORM_INF
));
remove
(
output_progressive
.
c_str
());
remove
(
output_normal
.
c_str
());
}
TEST
(
Imgcodecs_Jpeg
,
encode_decode_optimize_jpeg
)
{
cvtest
::
TS
&
ts
=
*
cvtest
::
TS
::
ptr
();
string
input
=
string
(
ts
.
get_data_path
())
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
input
);
ASSERT_FALSE
(
img
.
empty
());
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_JPEG_OPTIMIZE
);
params
.
push_back
(
1
);
string
output_optimized
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_optimized
,
img
,
params
));
cv
::
Mat
img_jpg_optimized
=
cv
::
imread
(
output_optimized
);
string
output_normal
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_normal
,
img
));
cv
::
Mat
img_jpg_normal
=
cv
::
imread
(
output_normal
);
EXPECT_EQ
(
0
,
cvtest
::
norm
(
img_jpg_optimized
,
img_jpg_normal
,
NORM_INF
));
remove
(
output_optimized
.
c_str
());
remove
(
output_normal
.
c_str
());
}
TEST
(
Imgcodecs_Jpeg
,
encode_decode_rst_jpeg
)
{
cvtest
::
TS
&
ts
=
*
cvtest
::
TS
::
ptr
();
string
input
=
string
(
ts
.
get_data_path
())
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
input
);
ASSERT_FALSE
(
img
.
empty
());
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_JPEG_RST_INTERVAL
);
params
.
push_back
(
1
);
string
output_rst
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_rst
,
img
,
params
));
cv
::
Mat
img_jpg_rst
=
cv
::
imread
(
output_rst
);
string
output_normal
=
cv
::
tempfile
(
".jpg"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output_normal
,
img
));
cv
::
Mat
img_jpg_normal
=
cv
::
imread
(
output_normal
);
EXPECT_EQ
(
0
,
cvtest
::
norm
(
img_jpg_rst
,
img_jpg_normal
,
NORM_INF
));
remove
(
output_rst
.
c_str
());
remove
(
output_normal
.
c_str
());
}
#endif // HAVE_JPEG
modules/imgcodecs/test/test_png.cpp
0 → 100644
View file @
d27009c7
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
::
tr1
;
#ifdef HAVE_PNG
TEST
(
Imgcodecs_Png
,
write_big
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filename
=
root
+
"readwrite/read.png"
;
const
string
dst_file
=
cv
::
tempfile
(
".png"
);
Mat
img
;
ASSERT_NO_THROW
(
img
=
imread
(
filename
));
ASSERT_FALSE
(
img
.
empty
());
EXPECT_EQ
(
13043
,
img
.
cols
);
EXPECT_EQ
(
13917
,
img
.
rows
);
ASSERT_NO_THROW
(
imwrite
(
dst_file
,
img
));
remove
(
dst_file
.
c_str
());
}
TEST
(
Imgcodecs_Png
,
encode
)
{
vector
<
uchar
>
buff
;
Mat
img_gt
=
Mat
::
zeros
(
1000
,
1000
,
CV_8U
);
vector
<
int
>
param
;
param
.
push_back
(
IMWRITE_PNG_COMPRESSION
);
param
.
push_back
(
3
);
//default(3) 0-9.
EXPECT_NO_THROW
(
imencode
(
".png"
,
img_gt
,
buff
,
param
));
Mat
img
;
EXPECT_NO_THROW
(
img
=
imdecode
(
buff
,
IMREAD_ANYDEPTH
));
// hang
EXPECT_FALSE
(
img
.
empty
());
EXPECT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
0
,
0
),
img
,
img_gt
);
}
TEST
(
Imgcodecs_Png
,
regression_ImreadVSCvtColor
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
imgName
=
root
+
"../cv/shared/lena.png"
;
Mat
original_image
=
imread
(
imgName
);
Mat
gray_by_codec
=
imread
(
imgName
,
IMREAD_GRAYSCALE
);
Mat
gray_by_cvt
;
cvtColor
(
original_image
,
gray_by_cvt
,
CV_BGR2GRAY
);
Mat
diff
;
absdiff
(
gray_by_codec
,
gray_by_cvt
,
diff
);
EXPECT_LT
(
cvtest
::
mean
(
diff
)[
0
],
1.
);
EXPECT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
10
,
0
),
gray_by_codec
,
gray_by_cvt
);
}
// Test OpenCV issue 3075 is solved
TEST
(
Imgcodecs_Png
,
read_color_palette_with_alpha
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
Mat
img
;
// First Test : Read PNG with alpha, imread flag -1
img
=
imread
(
root
+
"readwrite/color_palette_alpha.png"
,
IMREAD_UNCHANGED
);
ASSERT_FALSE
(
img
.
empty
());
ASSERT_TRUE
(
img
.
channels
()
==
4
);
// pixel is red in BGRA
EXPECT_EQ
(
img
.
at
<
Vec4b
>
(
0
,
0
),
Vec4b
(
0
,
0
,
255
,
255
));
EXPECT_EQ
(
img
.
at
<
Vec4b
>
(
0
,
1
),
Vec4b
(
0
,
0
,
255
,
255
));
// Second Test : Read PNG without alpha, imread flag -1
img
=
imread
(
root
+
"readwrite/color_palette_no_alpha.png"
,
IMREAD_UNCHANGED
);
ASSERT_FALSE
(
img
.
empty
());
ASSERT_TRUE
(
img
.
channels
()
==
3
);
// pixel is red in BGR
EXPECT_EQ
(
img
.
at
<
Vec3b
>
(
0
,
0
),
Vec3b
(
0
,
0
,
255
));
EXPECT_EQ
(
img
.
at
<
Vec3b
>
(
0
,
1
),
Vec3b
(
0
,
0
,
255
));
// Third Test : Read PNG with alpha, imread flag 1
img
=
imread
(
root
+
"readwrite/color_palette_alpha.png"
,
IMREAD_COLOR
);
ASSERT_FALSE
(
img
.
empty
());
ASSERT_TRUE
(
img
.
channels
()
==
3
);
// pixel is red in BGR
EXPECT_EQ
(
img
.
at
<
Vec3b
>
(
0
,
0
),
Vec3b
(
0
,
0
,
255
));
EXPECT_EQ
(
img
.
at
<
Vec3b
>
(
0
,
1
),
Vec3b
(
0
,
0
,
255
));
// Fourth Test : Read PNG without alpha, imread flag 1
img
=
imread
(
root
+
"readwrite/color_palette_no_alpha.png"
,
IMREAD_COLOR
);
ASSERT_FALSE
(
img
.
empty
());
ASSERT_TRUE
(
img
.
channels
()
==
3
);
// pixel is red in BGR
EXPECT_EQ
(
img
.
at
<
Vec3b
>
(
0
,
0
),
Vec3b
(
0
,
0
,
255
));
EXPECT_EQ
(
img
.
at
<
Vec3b
>
(
0
,
1
),
Vec3b
(
0
,
0
,
255
));
}
#endif // HAVE_PNG
modules/imgcodecs/test/test_precomp.hpp
View file @
d27009c7
...
...
@@ -9,7 +9,6 @@
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#include <iostream>
#include "opencv2/ts.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
...
...
@@ -17,4 +16,10 @@
#include "opencv2/core/private.hpp"
#include <fstream>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iterator>
#endif
modules/imgcodecs/test/test_read_write.cpp
0 → 100644
View file @
d27009c7
#include "test_precomp.hpp"
#include <fstream>
#include <sstream>
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
using
namespace
cvtest
;
TEST
(
Imgcodecs_Image
,
read_write_bmp
)
{
const
size_t
IMAGE_COUNT
=
10
;
const
double
thresDbell
=
32
;
for
(
size_t
i
=
0
;
i
<
IMAGE_COUNT
;
++
i
)
{
stringstream
s
;
s
<<
i
;
const
string
digit
=
s
.
str
();
const
string
src_name
=
TS
::
ptr
()
->
get_data_path
()
+
"../python/images/QCIF_0"
+
digit
+
".bmp"
;
const
string
dst_name
=
cv
::
tempfile
((
digit
+
".bmp"
).
c_str
());
Mat
image
=
imread
(
src_name
);
ASSERT_FALSE
(
image
.
empty
());
resize
(
image
,
image
,
Size
(
968
,
757
),
0.0
,
0.0
,
INTER_CUBIC
);
imwrite
(
dst_name
,
image
);
Mat
loaded
=
imread
(
dst_name
);
ASSERT_FALSE
(
loaded
.
empty
());
double
psnr
=
cvtest
::
PSNR
(
loaded
,
image
);
EXPECT_GT
(
psnr
,
thresDbell
);
vector
<
uchar
>
from_file
;
FILE
*
f
=
fopen
(
dst_name
.
c_str
(),
"rb"
);
fseek
(
f
,
0
,
SEEK_END
);
long
len
=
ftell
(
f
);
from_file
.
resize
((
size_t
)
len
);
fseek
(
f
,
0
,
SEEK_SET
);
from_file
.
resize
(
fread
(
&
from_file
[
0
],
1
,
from_file
.
size
(),
f
));
fclose
(
f
);
vector
<
uchar
>
buf
;
imencode
(
".bmp"
,
image
,
buf
);
ASSERT_EQ
(
buf
,
from_file
);
Mat
buf_loaded
=
imdecode
(
Mat
(
buf
),
1
);
ASSERT_FALSE
(
buf_loaded
.
empty
());
psnr
=
cvtest
::
PSNR
(
buf_loaded
,
image
);
EXPECT_GT
(
psnr
,
thresDbell
);
remove
(
dst_name
.
c_str
());
}
}
//==================================================================================================
typedef
string
Ext
;
typedef
testing
::
TestWithParam
<
Ext
>
Imgcodecs_Image
;
TEST_P
(
Imgcodecs_Image
,
read_write
)
{
const
string
ext
=
this
->
GetParam
();
const
string
full_name
=
cv
::
tempfile
(
ext
.
c_str
());
const
string
_name
=
TS
::
ptr
()
->
get_data_path
()
+
"../cv/shared/baboon.png"
;
const
double
thresDbell
=
32
;
Mat
image
=
imread
(
_name
);
image
.
convertTo
(
image
,
CV_8UC3
);
ASSERT_FALSE
(
image
.
empty
());
imwrite
(
full_name
,
image
);
Mat
loaded
=
imread
(
full_name
);
ASSERT_FALSE
(
loaded
.
empty
());
double
psnr
=
cvtest
::
PSNR
(
loaded
,
image
);
EXPECT_GT
(
psnr
,
thresDbell
);
vector
<
uchar
>
from_file
;
FILE
*
f
=
fopen
(
full_name
.
c_str
(),
"rb"
);
fseek
(
f
,
0
,
SEEK_END
);
long
len
=
ftell
(
f
);
from_file
.
resize
((
size_t
)
len
);
fseek
(
f
,
0
,
SEEK_SET
);
from_file
.
resize
(
fread
(
&
from_file
[
0
],
1
,
from_file
.
size
(),
f
));
fclose
(
f
);
vector
<
uchar
>
buf
;
imencode
(
"."
+
ext
,
image
,
buf
);
ASSERT_EQ
(
buf
,
from_file
);
Mat
buf_loaded
=
imdecode
(
Mat
(
buf
),
1
);
ASSERT_FALSE
(
buf_loaded
.
empty
());
psnr
=
cvtest
::
PSNR
(
buf_loaded
,
image
);
EXPECT_GT
(
psnr
,
thresDbell
);
remove
(
full_name
.
c_str
());
}
const
string
exts
[]
=
{
#ifdef HAVE_PNG
"png"
,
#endif
#ifdef HAVE_TIFF
"tiff"
,
#endif
#ifdef HAVE_JPEG
"jpg"
,
#endif
#ifdef HAVE_JASPER
"jp2"
,
#endif
#if 0 /*defined HAVE_OPENEXR && !defined __APPLE__*/
"exr",
#endif
"bmp"
,
"ppm"
,
"ras"
};
INSTANTIATE_TEST_CASE_P
(
imgcodecs
,
Imgcodecs_Image
,
testing
::
ValuesIn
(
exts
));
modules/imgcodecs/test/test_tiff.cpp
0 → 100644
View file @
d27009c7
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
::
tr1
;
#ifdef HAVE_TIFF
// these defines are used to resolve conflict between tiff.h and opencv2/core/types_c.h
#define uint64 uint64_hack_
#define int64 int64_hack_
#include "tiff.h"
#ifdef ANDROID
// Test disabled as it uses a lot of memory.
// It is killed with SIGKILL by out of memory killer.
TEST
(
Imgcodecs_Tiff
,
DISABLED_decode_tile16384x16384
)
#else
TEST
(
Imgcodecs_Tiff
,
decode_tile16384x16384
)
#endif
{
// see issue #2161
cv
::
Mat
big
(
16384
,
16384
,
CV_8UC1
,
cv
::
Scalar
::
all
(
0
));
string
file3
=
cv
::
tempfile
(
".tiff"
);
string
file4
=
cv
::
tempfile
(
".tiff"
);
std
::
vector
<
int
>
params
;
params
.
push_back
(
TIFFTAG_ROWSPERSTRIP
);
params
.
push_back
(
big
.
rows
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
file4
,
big
,
params
));
EXPECT_NO_THROW
(
cv
::
imwrite
(
file3
,
big
.
colRange
(
0
,
big
.
cols
-
1
),
params
));
big
.
release
();
try
{
cv
::
imread
(
file3
,
IMREAD_UNCHANGED
);
EXPECT_NO_THROW
(
cv
::
imread
(
file4
,
IMREAD_UNCHANGED
));
}
catch
(
const
std
::
bad_alloc
&
)
{
// not enough memory
}
remove
(
file3
.
c_str
());
remove
(
file4
.
c_str
());
}
TEST
(
Imgcodecs_Tiff
,
write_read_16bit_big_little_endian
)
{
// see issue #2601 "16-bit Grayscale TIFF Load Failures Due to Buffer Underflow and Endianness"
// Setup data for two minimal 16-bit grayscale TIFF files in both endian formats
uchar
tiff_sample_data
[
2
][
86
]
=
{
{
// Little endian
0x49
,
0x49
,
0x2a
,
0x00
,
0x0c
,
0x00
,
0x00
,
0x00
,
0xad
,
0xde
,
0xef
,
0xbe
,
0x06
,
0x00
,
0x00
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x02
,
0x00
,
0x00
,
0x00
,
0x01
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x02
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x06
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x11
,
0x01
,
0x04
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x00
,
0x00
,
0x17
,
0x01
,
0x04
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
},
{
// Big endian
0x4d
,
0x4d
,
0x00
,
0x2a
,
0x00
,
0x00
,
0x00
,
0x0c
,
0xde
,
0xad
,
0xbe
,
0xef
,
0x00
,
0x06
,
0x01
,
0x00
,
0x00
,
0x03
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x02
,
0x00
,
0x00
,
0x01
,
0x01
,
0x00
,
0x03
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x01
,
0x02
,
0x00
,
0x03
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x10
,
0x00
,
0x00
,
0x01
,
0x06
,
0x00
,
0x03
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x01
,
0x11
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x08
,
0x01
,
0x17
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x04
}
};
// Test imread() for both a little endian TIFF and big endian TIFF
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
string
filename
=
cv
::
tempfile
(
".tiff"
);
// Write sample TIFF file
FILE
*
fp
=
fopen
(
filename
.
c_str
(),
"wb"
);
ASSERT_TRUE
(
fp
!=
NULL
);
ASSERT_EQ
((
size_t
)
1
,
fwrite
(
tiff_sample_data
,
86
,
1
,
fp
));
fclose
(
fp
);
Mat
img
=
imread
(
filename
,
IMREAD_UNCHANGED
);
EXPECT_EQ
(
1
,
img
.
rows
);
EXPECT_EQ
(
2
,
img
.
cols
);
EXPECT_EQ
(
CV_16U
,
img
.
type
());
EXPECT_EQ
(
sizeof
(
ushort
),
img
.
elemSize
());
EXPECT_EQ
(
1
,
img
.
channels
());
EXPECT_EQ
(
0xDEAD
,
img
.
at
<
ushort
>
(
0
,
0
));
EXPECT_EQ
(
0xBEEF
,
img
.
at
<
ushort
>
(
0
,
1
));
remove
(
filename
.
c_str
());
}
}
TEST
(
Imgcodecs_Tiff
,
decode_tile_remainder
)
{
/* see issue #3472 - dealing with tiled images where the tile size is
* not a multiple of image size.
* The tiled images were created with 'convert' from ImageMagick,
* using the command 'convert <input> -define tiff:tile-geometry=128x128 -depth [8|16] <output>
* Note that the conversion to 16 bits expands the range from 0-255 to 0-255*255,
* so the test converts back but rounding errors cause small differences.
*/
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
cv
::
Mat
img
=
imread
(
root
+
"readwrite/non_tiled.tif"
,
-
1
);
ASSERT_FALSE
(
img
.
empty
());
ASSERT_TRUE
(
img
.
channels
()
==
3
);
cv
::
Mat
tiled8
=
imread
(
root
+
"readwrite/tiled_8.tif"
,
-
1
);
ASSERT_FALSE
(
tiled8
.
empty
());
ASSERT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
0
,
0
),
img
,
tiled8
);
cv
::
Mat
tiled16
=
imread
(
root
+
"readwrite/tiled_16.tif"
,
-
1
);
ASSERT_FALSE
(
tiled16
.
empty
());
ASSERT_TRUE
(
tiled16
.
elemSize
()
==
6
);
tiled16
.
convertTo
(
tiled8
,
CV_8UC3
,
1.
/
256.
);
ASSERT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
2
,
0
),
img
,
tiled8
);
// What about 32, 64 bit?
}
TEST
(
Imgcodecs_Tiff
,
decode_infinite_rowsperstrip
)
{
const
uchar
sample_data
[
142
]
=
{
0x49
,
0x49
,
0x2a
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x56
,
0x54
,
0x56
,
0x5a
,
0x59
,
0x55
,
0x5a
,
0x00
,
0x0a
,
0x00
,
0x00
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x07
,
0x00
,
0x00
,
0x00
,
0x02
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x00
,
0x00
,
0x03
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x06
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x11
,
0x01
,
0x04
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x00
,
0x00
,
0x15
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x16
,
0x01
,
0x04
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0xff
,
0xff
,
0x17
,
0x01
,
0x04
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x07
,
0x00
,
0x00
,
0x00
,
0x1c
,
0x01
,
0x03
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x02
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
const
string
filename
=
cv
::
tempfile
(
".tiff"
);
std
::
ofstream
outfile
(
filename
.
c_str
(),
std
::
ofstream
::
binary
);
outfile
.
write
(
reinterpret_cast
<
const
char
*>
(
sample_data
),
sizeof
sample_data
);
outfile
.
close
();
EXPECT_NO_THROW
(
cv
::
imread
(
filename
,
IMREAD_UNCHANGED
));
remove
(
filename
.
c_str
());
}
//==================================================================================================
typedef
testing
::
TestWithParam
<
int
>
Imgcodecs_Tiff_Modes
;
TEST_P
(
Imgcodecs_Tiff_Modes
,
decode_multipage
)
{
const
int
mode
=
GetParam
();
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filename
=
root
+
"readwrite/multipage.tif"
;
const
string
page_files
[]
=
{
"readwrite/multipage_p1.tif"
,
"readwrite/multipage_p2.tif"
,
"readwrite/multipage_p3.tif"
,
"readwrite/multipage_p4.tif"
,
"readwrite/multipage_p5.tif"
,
"readwrite/multipage_p6.tif"
};
const
size_t
page_count
=
sizeof
(
page_files
)
/
sizeof
(
page_files
[
0
]);
vector
<
Mat
>
pages
;
bool
res
=
imreadmulti
(
filename
,
pages
,
mode
);
ASSERT_TRUE
(
res
==
true
);
ASSERT_EQ
(
page_count
,
pages
.
size
());
for
(
size_t
i
=
0
;
i
<
page_count
;
i
++
)
{
const
Mat
page
=
imread
(
root
+
page_files
[
i
],
mode
);
EXPECT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
0
,
0
),
page
,
pages
[
i
]);
}
}
const
int
all_modes
[]
=
{
IMREAD_UNCHANGED
,
IMREAD_GRAYSCALE
,
IMREAD_COLOR
,
IMREAD_ANYDEPTH
,
IMREAD_ANYCOLOR
};
INSTANTIATE_TEST_CASE_P
(
AllModes
,
Imgcodecs_Tiff_Modes
,
testing
::
ValuesIn
(
all_modes
));
//==================================================================================================
TEST
(
Imgcodecs_Tiff
,
imdecode_no_exception_temporary_file_removed
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
const
string
filename
=
root
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
filename
);
ASSERT_FALSE
(
img
.
empty
());
std
::
vector
<
uchar
>
buf
;
EXPECT_NO_THROW
(
cv
::
imencode
(
".tiff"
,
img
,
buf
));
EXPECT_NO_THROW
(
cv
::
imdecode
(
buf
,
IMREAD_UNCHANGED
));
}
#endif
modules/imgcodecs/test/test_webp.cpp
0 → 100644
View file @
d27009c7
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
::
tr1
;
#ifdef HAVE_WEBP
TEST
(
Imgcodecs_WebP
,
encode_decode_lossless_webp
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
string
filename
=
root
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
filename
);
ASSERT_FALSE
(
img
.
empty
());
string
output
=
cv
::
tempfile
(
".webp"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output
,
img
));
// lossless
cv
::
Mat
img_webp
=
cv
::
imread
(
output
);
std
::
vector
<
unsigned
char
>
buf
;
FILE
*
wfile
=
NULL
;
wfile
=
fopen
(
output
.
c_str
(),
"rb"
);
if
(
wfile
!=
NULL
)
{
fseek
(
wfile
,
0
,
SEEK_END
);
size_t
wfile_size
=
ftell
(
wfile
);
fseek
(
wfile
,
0
,
SEEK_SET
);
buf
.
resize
(
wfile_size
);
size_t
data_size
=
fread
(
&
buf
[
0
],
1
,
wfile_size
,
wfile
);
if
(
wfile
)
{
fclose
(
wfile
);
}
if
(
data_size
!=
wfile_size
)
{
EXPECT_TRUE
(
false
);
}
}
remove
(
output
.
c_str
());
cv
::
Mat
decode
=
cv
::
imdecode
(
buf
,
IMREAD_COLOR
);
ASSERT_FALSE
(
decode
.
empty
());
EXPECT_TRUE
(
cvtest
::
norm
(
decode
,
img_webp
,
NORM_INF
)
==
0
);
ASSERT_FALSE
(
img_webp
.
empty
());
EXPECT_TRUE
(
cvtest
::
norm
(
img
,
img_webp
,
NORM_INF
)
==
0
);
}
TEST
(
Imgcodecs_WebP
,
encode_decode_lossy_webp
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
std
::
string
input
=
root
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
input
);
ASSERT_FALSE
(
img
.
empty
());
for
(
int
q
=
100
;
q
>=
0
;
q
-=
20
)
{
std
::
vector
<
int
>
params
;
params
.
push_back
(
IMWRITE_WEBP_QUALITY
);
params
.
push_back
(
q
);
string
output
=
cv
::
tempfile
(
".webp"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output
,
img
,
params
));
cv
::
Mat
img_webp
=
cv
::
imread
(
output
);
remove
(
output
.
c_str
());
EXPECT_FALSE
(
img_webp
.
empty
());
EXPECT_EQ
(
3
,
img_webp
.
channels
());
EXPECT_EQ
(
512
,
img_webp
.
cols
);
EXPECT_EQ
(
512
,
img_webp
.
rows
);
}
}
TEST
(
Imgcodecs_WebP
,
encode_decode_with_alpha_webp
)
{
const
string
root
=
cvtest
::
TS
::
ptr
()
->
get_data_path
();
std
::
string
input
=
root
+
"../cv/shared/lena.png"
;
cv
::
Mat
img
=
cv
::
imread
(
input
);
ASSERT_FALSE
(
img
.
empty
());
std
::
vector
<
cv
::
Mat
>
imgs
;
cv
::
split
(
img
,
imgs
);
imgs
.
push_back
(
cv
::
Mat
(
imgs
[
0
]));
imgs
[
imgs
.
size
()
-
1
]
=
cv
::
Scalar
::
all
(
128
);
cv
::
merge
(
imgs
,
img
);
string
output
=
cv
::
tempfile
(
".webp"
);
EXPECT_NO_THROW
(
cv
::
imwrite
(
output
,
img
));
cv
::
Mat
img_webp
=
cv
::
imread
(
output
);
remove
(
output
.
c_str
());
EXPECT_FALSE
(
img_webp
.
empty
());
EXPECT_EQ
(
4
,
img_webp
.
channels
());
EXPECT_EQ
(
512
,
img_webp
.
cols
);
EXPECT_EQ
(
512
,
img_webp
.
rows
);
}
#endif // HAVE_WEBP
modules/superres/test/test_precomp.hpp
View file @
d27009c7
...
...
@@ -59,17 +59,4 @@
#include "cvconfig.h"
#include "../src/input_array_utility.hpp"
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF) || \
defined(HAVE_VFW)
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#endif
modules/superres/test/test_superres.cpp
View file @
d27009c7
...
...
@@ -43,7 +43,7 @@
#include "test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
class
AllignedFrameSource
:
public
cv
::
superres
::
FrameSource
{
...
...
@@ -295,4 +295,4 @@ OCL_TEST_F(SuperResolution, BTVL1)
#endif
#endif //
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#endif //
HAVE_VIDEO_INPU
T
modules/ts/src/ts_func.cpp
View file @
d27009c7
...
...
@@ -2947,9 +2947,9 @@ MatComparator::operator()(const char* expr1, const char* expr2,
return
::
testing
::
AssertionFailure
()
<<
"too big relative difference ("
<<
realmaxdiff
<<
" > "
<<
maxdiff
<<
") between "
<<
MatInfo
(
m1
)
<<
" '"
<<
expr1
<<
"' and '"
<<
expr2
<<
"' at "
<<
Mat
(
loc0
)
<<
".
\n
\n
"
<<
"
'"
<<
expr1
<<
"': "
<<
MatPart
(
m1part
,
border
>
0
?
&
loc
:
0
)
<<
".
\n
\n
"
<<
"
'"
<<
expr2
<<
"':
"
<<
MatPart
(
m2part
,
border
>
0
?
&
loc
:
0
)
<<
".
\n
"
;
<<
MatInfo
(
m1
)
<<
" '"
<<
expr1
<<
"' and '"
<<
expr2
<<
"' at "
<<
Mat
(
loc0
)
.
t
()
<<
".
\n
"
<<
"
- "
<<
expr1
<<
":
\n
"
<<
MatPart
(
m1part
,
border
>
0
?
&
loc
:
0
)
<<
".
\n
"
<<
"
- "
<<
expr2
<<
":
\n
"
<<
MatPart
(
m2part
,
border
>
0
?
&
loc
:
0
)
<<
".
\n
"
;
}
void
printVersionInfo
(
bool
useStdOut
)
...
...
modules/video/perf/opencl/perf_bgfg_mog2.cpp
View file @
d27009c7
...
...
@@ -2,20 +2,7 @@
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32)
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
#ifdef HAVE_VIDEO_INPUT
namespace
cvtest
{
namespace
ocl
{
...
...
@@ -116,5 +103,5 @@ OCL_PERF_TEST_P(MOG2_GetBackgroundImage, Mog2, Combine(Values("gpu/video/768x576
}}
// namespace cvtest::ocl
#endif
#endif
\ No newline at end of file
#endif
#endif
modules/video/test/ocl/test_bgfg_mog2.cpp
View file @
d27009c7
...
...
@@ -2,20 +2,7 @@
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32)
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
#ifdef HAVE_VIDEO_INPUT
namespace
cvtest
{
namespace
ocl
{
...
...
@@ -154,5 +141,5 @@ OCL_INSTANTIATE_TEST_CASE_P(OCL_Video, Mog2_getBackgroundImage, Combine(
}}
// namespace cvtest::ocl
#endif
#endif
#endif
modules/videoio/perf/perf_input.cpp
View file @
d27009c7
#include "perf_precomp.hpp"
#if
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#if
def HAVE_VIDEO_INPU
T
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -11,21 +11,19 @@ using std::tr1::get;
typedef
perf
::
TestBaseWithParam
<
std
::
string
>
VideoCapture_Reading
;
#if defined(HAVE_MSMF)
// MPEG2 is not supported by Media Foundation yet
// http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
PERF_TEST_P
(
VideoCapture_Reading
,
ReadFile
,
testing
::
Values
(
"highgui/video/big_buck_bunny.avi"
,
"highgui/video/big_buck_bunny.mov"
,
"highgui/video/big_buck_bunny.mp4"
,
"highgui/video/big_buck_bunny.wmv"
)
)
#else
PERF_TEST_P
(
VideoCapture_Reading
,
ReadFile
,
testing
::
Values
(
"highgui/video/big_buck_bunny.avi"
,
"highgui/video/big_buck_bunny.mov"
,
"highgui/video/big_buck_bunny.mp4"
,
"highgui/video/big_buck_bunny.mpg"
,
"highgui/video/big_buck_bunny.wmv"
)
)
const
string
bunny_files
[]
=
{
"highgui/video/big_buck_bunny.avi"
,
"highgui/video/big_buck_bunny.mov"
,
"highgui/video/big_buck_bunny.mp4"
,
#ifndef HAVE_MSMF
// MPEG2 is not supported by Media Foundation yet
// http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
"highgui/video/big_buck_bunny.mpg"
,
#endif
"highgui/video/big_buck_bunny.wmv"
};
PERF_TEST_P
(
VideoCapture_Reading
,
ReadFile
,
testing
::
ValuesIn
(
bunny_files
)
)
{
string
filename
=
getDataPath
(
GetParam
());
...
...
@@ -33,8 +31,7 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_
TEST_CYCLE
()
cap
.
open
(
filename
);
bool
dummy
=
cap
.
isOpened
();
SANITY_CHECK
(
dummy
);
SANITY_CHECK_NOTHING
();
}
#endif //
BUILD_WITH_VIDEO_INPUT_SUPPOR
T
#endif //
HAVE_VIDEO_INPU
T
modules/videoio/perf/perf_output.cpp
View file @
d27009c7
#include "perf_precomp.hpp"
#if
BUILD_WITH_VIDEO_OUTPUT_SUPPOR
T
#if
def HAVE_VIDEO_OUTPU
T
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -11,30 +11,35 @@ using std::tr1::get;
typedef
std
::
tr1
::
tuple
<
std
::
string
,
bool
>
VideoWriter_Writing_t
;
typedef
perf
::
TestBaseWithParam
<
VideoWriter_Writing_t
>
VideoWriter_Writing
;
const
string
image_files
[]
=
{
"python/images/QCIF_00.bmp"
,
"python/images/QCIF_01.bmp"
,
"python/images/QCIF_02.bmp"
,
"python/images/QCIF_03.bmp"
,
"python/images/QCIF_04.bmp"
,
"python/images/QCIF_05.bmp"
};
PERF_TEST_P
(
VideoWriter_Writing
,
WriteFrame
,
testing
::
Combine
(
testing
::
Values
(
"python/images/QCIF_00.bmp"
,
"python/images/QCIF_01.bmp"
,
"python/images/QCIF_02.bmp"
,
"python/images/QCIF_03.bmp"
,
"python/images/QCIF_04.bmp"
,
"python/images/QCIF_05.bmp"
),
testing
::
Bool
()))
testing
::
Combine
(
testing
::
ValuesIn
(
image_files
),
testing
::
Bool
()))
{
string
filename
=
getDataPath
(
get
<
0
>
(
GetParam
()));
bool
isColor
=
get
<
1
>
(
GetParam
());
const
string
filename
=
getDataPath
(
get
<
0
>
(
GetParam
()));
const
bool
isColor
=
get
<
1
>
(
GetParam
());
Mat
image
=
imread
(
filename
,
1
);
#if defined(HAVE_MSMF) && !defined(HAVE_VFW) && !defined(HAVE_FFMPEG) // VFW has greater priority
VideoWriter
writer
(
cv
::
tempfile
(
".wmv"
),
VideoWriter
::
fourcc
(
'W'
,
'M'
,
'V'
,
'3'
),
25
,
cv
::
Size
(
image
.
cols
,
image
.
rows
),
isColor
);
const
string
outfile
=
cv
::
tempfile
(
".wmv"
);
const
int
fourcc
=
VideoWriter
::
fourcc
(
'W'
,
'M'
,
'V'
,
'3'
);
#else
VideoWriter
writer
(
cv
::
tempfile
(
".avi"
),
VideoWriter
::
fourcc
(
'X'
,
'V'
,
'I'
,
'D'
),
25
,
cv
::
Size
(
image
.
cols
,
image
.
rows
),
isColor
);
const
string
outfile
=
cv
::
tempfile
(
".avi"
);
const
int
fourcc
=
VideoWriter
::
fourcc
(
'X'
,
'V'
,
'I'
,
'D'
);
#endif
TEST_CYCLE
()
{
image
=
imread
(
filename
,
1
);
writer
<<
image
;
}
bool
dummy
=
writer
.
isOpened
();
SANITY_CHECK
(
dummy
);
VideoWriter
writer
(
outfile
,
fourcc
,
25
,
cv
::
Size
(
image
.
cols
,
image
.
rows
),
isColor
);
TEST_CYCLE_N
(
100
)
{
writer
<<
image
;
}
SANITY_CHECK_NOTHING
();
remove
(
outfile
.
c_str
()
);
}
#endif //
BUILD_WITH_VIDEO_OUTPUT_SUPPOR
T
#endif //
HAVE_VIDEO_OUTPU
T
modules/videoio/perf/perf_precomp.hpp
View file @
d27009c7
...
...
@@ -17,33 +17,4 @@
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF) || \
defined(HAVE_VFW)
/*defined(HAVE_OPENNI) too specialized */
\
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#if
/*defined(HAVE_XINE) || */
\
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF) || \
defined(HAVE_VFW)
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
#endif
#endif
modules/videoio/src/cap.cpp
View file @
d27009c7
...
...
@@ -181,11 +181,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
case
CV_CAP_MSMF
:
TRY_OPEN
(
capture
,
cvCreateCameraCapture_MSMF
(
index
))
if
(
pref
)
break
;
#endif
#ifdef HAVE_TYZX
case
CV_CAP_STEREO
:
TRY_OPEN
(
capture
,
cvCreateCameraCapture_TYZX
(
index
))
if
(
pref
)
break
;
#endif
case
CV_CAP_VFW
:
#ifdef HAVE_VFW
...
...
modules/videoio/src/precomp.hpp
View file @
d27009c7
...
...
@@ -108,7 +108,6 @@ CvCapture * cvCreateCameraCapture_DC1394_2( int index );
CvCapture
*
cvCreateCameraCapture_MIL
(
int
index
);
CvCapture
*
cvCreateCameraCapture_Giganetix
(
int
index
);
CvCapture
*
cvCreateCameraCapture_CMU
(
int
index
);
CV_IMPL
CvCapture
*
cvCreateCameraCapture_TYZX
(
int
index
);
CvCapture
*
cvCreateFileCapture_Win32
(
const
char
*
filename
);
CvCapture
*
cvCreateCameraCapture_VFW
(
int
index
);
CvCapture
*
cvCreateFileCapture_VFW
(
const
char
*
filename
);
...
...
modules/videoio/test/test_basic_props.cpp
deleted
100644 → 0
View file @
4eb5242e
/*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/videoio.hpp"
#include "opencv2/ts.hpp"
#include <stdio.h>
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
using
namespace
cv
;
using
namespace
std
;
using
namespace
cvtest
;
#ifdef HAVE_GSTREAMER
const
string
ext
[]
=
{
"avi"
};
#else
const
string
ext
[]
=
{
"avi"
,
"mov"
,
"mp4"
};
#endif
TEST
(
Videoio_Video
,
prop_resolution
)
{
const
size_t
n
=
sizeof
(
ext
)
/
sizeof
(
ext
[
0
]);
const
string
src_dir
=
TS
::
ptr
()
->
get_data_path
();
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n\n
Source files directory: %s
\n
"
,
(
src_dir
+
"video/"
).
c_str
());
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
string
file_path
=
src_dir
+
"video/big_buck_bunny."
+
ext
[
i
];
VideoCapture
cap
(
file_path
);
if
(
!
cap
.
isOpened
())
{
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
FAILED
\n\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: cannot read source video file.
\n
"
);
TS
::
ptr
()
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
ASSERT_EQ
(
672
,
cap
.
get
(
CAP_PROP_FRAME_WIDTH
));
ASSERT_EQ
(
384
,
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
));
}
}
TEST
(
Videoio_Video
,
actual_resolution
)
{
const
size_t
n
=
sizeof
(
ext
)
/
sizeof
(
ext
[
0
]);
const
string
src_dir
=
TS
::
ptr
()
->
get_data_path
();
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n\n
Source files directory: %s
\n
"
,
(
src_dir
+
"video/"
).
c_str
());
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
string
file_path
=
src_dir
+
"video/big_buck_bunny."
+
ext
[
i
];
VideoCapture
cap
(
file_path
);
if
(
!
cap
.
isOpened
())
{
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
FAILED
\n\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: cannot read source video file.
\n
"
);
TS
::
ptr
()
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
Mat
frame
;
cap
>>
frame
;
ASSERT_EQ
(
672
,
frame
.
cols
);
ASSERT_EQ
(
384
,
frame
.
rows
);
}
}
TEST
(
Videoio_Video
,
DISABLED_prop_fps
)
{
const
size_t
n
=
sizeof
(
ext
)
/
sizeof
(
ext
[
0
]);
const
string
src_dir
=
TS
::
ptr
()
->
get_data_path
();
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n\n
Source files directory: %s
\n
"
,
(
src_dir
+
"video/"
).
c_str
());
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
string
file_path
=
src_dir
+
"video/big_buck_bunny."
+
ext
[
i
];
VideoCapture
cap
(
file_path
);
if
(
!
cap
.
isOpened
())
{
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
FAILED
\n\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: cannot read source video file.
\n
"
);
TS
::
ptr
()
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
ASSERT_EQ
(
24
,
cap
.
get
(
CAP_PROP_FPS
));
}
}
TEST
(
Videoio_Video
,
prop_framecount
)
{
const
size_t
n
=
sizeof
(
ext
)
/
sizeof
(
ext
[
0
]);
const
string
src_dir
=
TS
::
ptr
()
->
get_data_path
();
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n\n
Source files directory: %s
\n
"
,
(
src_dir
+
"video/"
).
c_str
());
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
string
file_path
=
src_dir
+
"video/big_buck_bunny."
+
ext
[
i
];
VideoCapture
cap
(
file_path
);
if
(
!
cap
.
isOpened
())
{
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
FAILED
\n\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
TS
::
ptr
()
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: cannot read source video file.
\n
"
);
TS
::
ptr
()
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
ASSERT_EQ
(
125
,
cap
.
get
(
CAP_PROP_FRAME_COUNT
));
}
}
#endif
modules/videoio/test/test_framecount.cpp
deleted
100644 → 0
View file @
4eb5242e
/*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/videoio/videoio_c.h"
#include <stdio.h>
using
namespace
cv
;
using
namespace
std
;
class
CV_FramecountTest
:
public
cvtest
::
BaseTest
{
public
:
void
run
(
int
);
};
void
CV_FramecountTest
::
run
(
int
)
{
const
int
time_sec
=
5
,
fps
=
25
;
const
string
ext
[]
=
{
"avi"
,
"mov"
,
"mp4"
};
const
size_t
n
=
sizeof
(
ext
)
/
sizeof
(
ext
[
0
]);
const
string
src_dir
=
ts
->
get_data_path
();
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n\n
Source files directory: %s
\n
"
,
(
src_dir
+
"video/"
).
c_str
());
Ptr
<
CvCapture
>
cap
;
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
string
file_path
=
src_dir
+
"video/big_buck_bunny."
+
ext
[
i
];
cap
.
reset
(
cvCreateFileCapture
(
file_path
.
c_str
()));
if
(
!
cap
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
FAILED
\n\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: cannot read source video file.
\n
"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
//cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, 0);
IplImage
*
frame
;
int
FrameCount
=
0
;
for
(;;)
{
frame
=
cvQueryFrame
(
cap
);
if
(
!
frame
)
break
;
FrameCount
++
;
}
int
framecount
=
(
int
)
cvGetCaptureProperty
(
cap
,
CAP_PROP_FRAME_COUNT
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n
"
\
"
\n
Name: big_buck_bunny.%s
\n
Actual frame count: %d
\n
"
\
"Frame count computed in the cycle of queries of frames: %d
\n
"
\
"Frame count returned by cvGetCaptureProperty function: %d
\n
"
,
i
+
1
,
ext
[
i
].
c_str
(),
time_sec
*
fps
,
FrameCount
,
framecount
);
if
(
(
FrameCount
!=
cvRound
(
time_sec
*
fps
)
||
FrameCount
!=
framecount
)
&&
ext
[
i
]
!=
"mpg"
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"FAILED
\n
"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
Error: actual frame count and returned frame count are not matched.
\n
"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_OUTPUT
);
return
;
}
}
}
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
TEST
(
Videoio_Video
,
framecount
)
{
CV_FramecountTest
test
;
test
.
safe_run
();}
#endif
modules/videoio/test/test_positioning.cpp
deleted
100644 → 0
View file @
4eb5242e
/*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/videoio/videoio_c.h"
#include <stdio.h>
using
namespace
cv
;
using
namespace
std
;
class
CV_VideoPositioningTest
:
public
cvtest
::
BaseTest
{
public
:
enum
{
PROGRESSIVE
,
RANDOM
};
CV_VideoPositioningTest
();
~
CV_VideoPositioningTest
();
virtual
void
run
(
int
)
=
0
;
protected
:
vector
<
int
>
idx
;
void
run_test
(
int
method
);
private
:
void
generate_idx_seq
(
CvCapture
*
cap
,
int
method
);
};
class
CV_VideoProgressivePositioningTest
:
public
CV_VideoPositioningTest
{
public
:
CV_VideoProgressivePositioningTest
()
:
CV_VideoPositioningTest
()
{
}
~
CV_VideoProgressivePositioningTest
();
void
run
(
int
);
};
class
CV_VideoRandomPositioningTest
:
public
CV_VideoPositioningTest
{
public
:
CV_VideoRandomPositioningTest
()
:
CV_VideoPositioningTest
()
{
}
~
CV_VideoRandomPositioningTest
();
void
run
(
int
);
};
CV_VideoPositioningTest
::
CV_VideoPositioningTest
()
{}
CV_VideoPositioningTest
::~
CV_VideoPositioningTest
()
{}
CV_VideoProgressivePositioningTest
::~
CV_VideoProgressivePositioningTest
()
{}
CV_VideoRandomPositioningTest
::~
CV_VideoRandomPositioningTest
()
{}
void
CV_VideoPositioningTest
::
generate_idx_seq
(
CvCapture
*
cap
,
int
method
)
{
idx
.
clear
();
int
N
=
(
int
)
cvGetCaptureProperty
(
cap
,
CAP_PROP_FRAME_COUNT
);
switch
(
method
)
{
case
PROGRESSIVE
:
{
int
pos
=
1
,
step
=
20
;
do
{
idx
.
push_back
(
pos
);
pos
+=
step
;
}
while
(
pos
<=
N
);
break
;
}
case
RANDOM
:
{
RNG
rng
(
N
);
idx
.
clear
();
for
(
int
i
=
0
;
i
>=
0
&&
i
<
N
-
1
;
i
++
)
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
));
break
;
}
default
:
break
;
}
}
void
CV_VideoPositioningTest
::
run_test
(
int
method
)
{
const
string
&
src_dir
=
ts
->
get_data_path
();
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n\n
Source files directory: %s
\n
"
,
(
src_dir
+
"video/"
).
c_str
());
const
string
ext
[]
=
{
"avi"
,
"mov"
,
"mp4"
,
"mpg"
};
int
n
=
(
int
)(
sizeof
(
ext
)
/
sizeof
(
ext
[
0
]));
int
failed_videos
=
0
;
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
// skip random positioning test in plain mpegs
if
(
method
==
RANDOM
&&
ext
[
i
]
==
"mpg"
)
continue
;
string
file_path
=
src_dir
+
"video/big_buck_bunny."
+
ext
[
i
];
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
Reading video file in %s...
\n
"
,
file_path
.
c_str
());
CvCapture
*
cap
=
cvCreateFileCapture
(
file_path
.
c_str
());
if
(
!
cap
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
FAILED
\n\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: cannot read source video file.
\n
"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
failed_videos
++
;
continue
;
}
cvSetCaptureProperty
(
cap
,
CAP_PROP_POS_FRAMES
,
0
);
generate_idx_seq
(
cap
,
method
);
int
N
=
(
int
)
idx
.
size
(),
failed_frames
=
0
,
failed_positions
=
0
,
failed_iterations
=
0
;
for
(
int
j
=
0
;
j
<
N
;
++
j
)
{
bool
flag
=
false
;
cvSetCaptureProperty
(
cap
,
CAP_PROP_POS_FRAMES
,
idx
.
at
(
j
));
/* IplImage* frame = cvRetrieveFrame(cap);
if (!frame)
{
if (!failed_frames)
{
ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\n", i+1, ext[i].c_str());
}
failed_frames++;
ts->printf(cvtest::TS::LOG, "\nIteration: %d\n\nError: cannot read a frame with index %d.\n", j, idx.at(j));
ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
flag = !flag;
} */
int
val
=
(
int
)
cvGetCaptureProperty
(
cap
,
CAP_PROP_POS_FRAMES
);
if
(
idx
.
at
(
j
)
!=
val
)
{
if
(
!
(
failed_frames
||
failed_positions
))
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
File information (video %d):
\n\n
Name: big_buck_bunny.%s
\n
"
,
i
+
1
,
ext
[
i
].
c_str
());
}
failed_positions
++
;
if
(
!
failed_frames
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
Iteration: %d
\n
"
,
j
);
}
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Required pos: %d
\n
Returned pos: %d
\n
"
,
idx
.
at
(
j
),
val
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error: required and returned positions are not matched.
\n
"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_OUTPUT
);
flag
=
true
;
}
if
(
flag
)
{
failed_iterations
++
;
failed_videos
++
;
break
;
}
}
cvReleaseCapture
(
&
cap
);
}
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"
\n
Successfull experiments: %d (%d%%)
\n
"
,
n
-
failed_videos
,
100
*
(
n
-
failed_videos
)
/
n
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Failed experiments: %d (%d%%)
\n
"
,
failed_videos
,
100
*
failed_videos
/
n
);
}
void
CV_VideoProgressivePositioningTest
::
run
(
int
)
{
run_test
(
PROGRESSIVE
);
}
void
CV_VideoRandomPositioningTest
::
run
(
int
)
{
run_test
(
RANDOM
);
}
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
TEST
(
Videoio_Video
,
seek_progressive
)
{
CV_VideoProgressivePositioningTest
test
;
test
.
safe_run
();
}
TEST
(
Videoio_Video
,
seek_random
)
{
CV_VideoRandomPositioningTest
test
;
test
.
safe_run
();
}
#endif
modules/videoio/test/test_precomp.hpp
View file @
d27009c7
...
...
@@ -18,74 +18,29 @@
#include "opencv2/core/private.hpp"
#if defined(HAVE_DSHOW) || \
defined(HAVE_TYZX) || \
defined(HAVE_VFW) || \
defined(HAVE_LIBV4L) || \
(defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_DC1394_2) || \
defined(HAVE_DC1394) || \
defined(HAVE_CMU1394) || \
defined(HAVE_MIL) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_UNICAP) || \
defined(HAVE_PVAPI) || \
defined(HAVE_OPENNI) || \
defined(HAVE_XIMEA) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_GIGE_API) || \
defined(HAVE_INTELPERC) || \
defined(HAVE_GPHOTO2) || \
(0)
# define BUILD_WITH_CAMERA_SUPPORT 1
#else
# define BUILD_WITH_CAMERA_SUPPORT 0
#endif
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
/*defined(HAVE_OPENNI) || too specialized */
\
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF)
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#if
/*defined(HAVE_XINE) || */
\
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF)
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
#endif
namespace
cvtest
inline
std
::
string
fourccToString
(
int
fourcc
)
{
return
cv
::
format
(
"%c%c%c%c"
,
fourcc
&
255
,
(
fourcc
>>
8
)
&
255
,
(
fourcc
>>
16
)
&
255
,
(
fourcc
>>
24
)
&
255
);
}
string
fourccToString
(
int
fourcc
);
struct
VideoFormat
inline
int
fourccFromString
(
const
std
::
string
&
fourcc
)
{
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
[];
if
(
fourcc
.
size
()
!=
4
)
return
0
;
return
cv
::
VideoWriter
::
fourcc
(
fourcc
[
0
],
fourcc
[
1
],
fourcc
[
2
],
fourcc
[
3
]);
}
inline
void
generateFrame
(
int
i
,
int
FRAME_COUNT
,
cv
::
Mat
&
frame
)
{
using
namespace
cv
;
using
namespace
std
;
frame
=
Scalar
(
30
,
140
,
10
);
ostringstream
buf
;
buf
<<
"Frame "
<<
setw
(
2
)
<<
setfill
(
'0'
)
<<
i
+
1
;
int
baseLine
=
0
;
Size
box
=
getTextSize
(
buf
.
str
(),
FONT_HERSHEY_COMPLEX
,
2
,
5
,
&
baseLine
);
putText
(
frame
,
buf
.
str
(),
Point
((
frame
.
cols
-
box
.
width
)
/
2
,
(
frame
.
rows
-
box
.
height
)
/
2
+
baseLine
),
FONT_HERSHEY_COMPLEX
,
2
,
Scalar
(
255
,
255
,
255
),
5
,
LINE_AA
);
Point
p
(
i
*
frame
.
cols
/
(
FRAME_COUNT
-
1
),
i
*
frame
.
rows
/
(
FRAME_COUNT
-
1
));
circle
(
frame
,
p
,
20
,
Scalar
(
200
,
25
,
55
),
5
,
LINE_AA
);
}
#endif
modules/videoio/test/test_video_io.cpp
View file @
d27009c7
This diff is collapsed.
Click to expand it.
modules/videoio/test/test_video_pos.cpp
deleted
100644 → 0
View file @
4eb5242e
/*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/videoio.hpp"
using
namespace
cv
;
using
namespace
std
;
class
CV_PositioningTest
:
public
cvtest
::
BaseTest
{
public
:
CV_PositioningTest
()
{
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
cv
::
tempfile
((
cvtest
::
fourccToString
(
fmt
.
fourcc
)
+
"."
+
fmt
.
ext
).
c_str
());
}
bool
CreateTestVideo
(
const
cvtest
::
VideoFormat
&
fmt
,
int
framecount
,
string
filename
)
{
VideoWriter
writer
(
filename
,
fmt
.
fourcc
,
25
,
framesize
,
true
);
if
(
!
writer
.
isOpened
()
)
return
false
;
for
(
int
i
=
0
;
i
<
framecount
;
++
i
)
{
Mat
img
=
drawFrame
(
i
);
writer
<<
img
;
}
return
true
;
}
void
run
(
int
)
{
int
n_frames
=
100
;
for
(
int
testcase
=
0
;
;
testcase
++
)
{
const
cvtest
::
VideoFormat
&
fmt
=
cvtest
::
g_specific_fmt_list
[
testcase
];
if
(
fmt
.
empty
()
)
break
;
string
filename
=
getFilename
(
fmt
);
ts
->
printf
(
ts
->
LOG
,
"
\n
File: %s
\n
"
,
filename
.
c_str
());
if
(
!
CreateTestVideo
(
fmt
,
n_frames
,
filename
)
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot create video file"
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
return
;
}
VideoCapture
cap
(
filename
);
if
(
!
cap
.
isOpened
())
{
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: cannot read video file."
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_TEST_DATA
);
return
;
}
int
N0
=
(
int
)
cap
.
get
(
CAP_PROP_FRAME_COUNT
);
cap
.
set
(
CAP_PROP_POS_FRAMES
,
0
);
int
N
=
(
int
)
cap
.
get
(
CAP_PROP_FRAME_COUNT
);
// See the same hack in CV_VideoIOTest::SpecificVideoTest for explanation.
int
allowed_extra_frames
=
0
;
if
(
fmt
.
fourcc
==
VideoWriter
::
fourcc
(
'M'
,
'P'
,
'E'
,
'G'
)
&&
fmt
.
ext
==
"mkv"
)
allowed_extra_frames
=
1
;
if
(
N
<
n_frames
||
N
>
n_frames
+
allowed_extra_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_frames
;
++
k
)
{
int
idx
=
theRNG
().
uniform
(
0
,
n_frames
);
if
(
!
cap
.
set
(
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
;
}
int
idx1
=
(
int
)
cap
.
get
(
CAP_PROP_POS_FRAMES
);
Mat
img
;
cap
>>
img
;
Mat
img0
=
drawFrame
(
idx
);
if
(
idx
!=
idx1
)
{
ts
->
printf
(
ts
->
LOG
,
"
\n
Error: the current position (%d) after seek is different from specified (%d)
\n
"
,
idx1
,
idx
);
ts
->
printf
(
ts
->
LOG
,
"Saving both frames ...
\n
"
);
ts
->
set_failed_test_info
(
ts
->
FAIL_INVALID_OUTPUT
);
return
;
}
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
;
}
double
err
=
cvtest
::
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
);
return
;
}
}
}
}
Size
framesize
;
};
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT && defined HAVE_FFMPEG
TEST
(
Videoio_Video
,
seek_random_synthetic
)
{
CV_PositioningTest
test
;
test
.
safe_run
();
}
#endif
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