Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
03c77841
O
Opencv
项目概览
Greenplum
/
Opencv
12 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
03c77841
编写于
6月 03, 2011
作者:
A
Andrey Morozov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added several new highgui tests
上级
22dbd002
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
119 addition
and
57 deletion
+119
-57
modules/highgui/test/test_ffmpeg.cpp
modules/highgui/test/test_ffmpeg.cpp
+115
-53
modules/highgui/test/test_video_io.cpp
modules/highgui/test/test_video_io.cpp
+4
-4
未找到文件。
modules/highgui/test/test_ffmpeg.cpp
浏览文件 @
03c77841
...
...
@@ -78,19 +78,21 @@ class CV_FFmpegWriteBigVideoTest : public cvtest::BaseTest
const
int
img_c
=
4096
;
Size
frame_s
=
Size
(
img_c
,
img_r
);
const
double
fps
=
30
;
const
double
time_sec
=
1
;
const
double
time_sec
=
2
;
const
int
coeff
=
static_cast
<
int
>
(
static_cast
<
double
>
(
cv
::
min
(
img_c
,
img_r
))
/
(
fps
*
time_sec
));
Mat
img
(
img_r
,
img_c
,
CV_8UC3
,
Scalar
::
all
(
0
));
try
{
VideoWriter
writer
(
string
(
ts
->
get_data_path
())
+
"video/output.avi"
,
CV_FOURCC
(
'X'
,
'V'
,
'I'
,
'D'
),
fps
,
frame_s
);
VideoWriter
writer
(
string
(
ts
->
get_data_path
())
+
"video/output.avi"
,
CV_FOURCC
(
'X'
,
'V'
,
'I'
,
'D'
),
fps
,
frame_s
);
if
(
writer
.
isOpened
()
==
false
)
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_EXCEPTION
);
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
fps
*
time_sec
);
i
++
)
{
circle
(
img
,
Point2i
(
img_c
/
2
,
img_r
/
2
),
cv
::
min
(
img_r
,
img_c
)
/
2
*
(
i
+
1
),
Scalar
::
all
(
255
));
//circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2);
rectangle
(
img
,
Point2i
(
coeff
*
i
,
coeff
*
i
),
Point2i
(
coeff
*
(
i
+
1
),
coeff
*
(
i
+
1
)),
Scalar
::
all
(
255
*
(
1.0
-
static_cast
<
double
>
(
i
)
/
(
fps
*
time_sec
*
2
)
)),
-
1
);
writer
<<
img
;
}
}
...
...
@@ -105,55 +107,115 @@ class CV_FFmpegWriteBigVideoTest : public cvtest::BaseTest
string
ext_from_int
(
int
ext
)
{
if
(
ext
==
0
)
return
".png"
;
if
(
ext
==
1
)
return
".jpg"
;
if
(
ext
==
2
)
return
".bmp"
;
if
(
ext
==
3
)
return
".pgm"
;
if
(
ext
==
4
)
return
".tiff"
;
if
(
ext
==
1
)
return
".bmp"
;
if
(
ext
==
2
)
return
".pgm"
;
if
(
ext
==
3
)
return
".tiff"
;
return
""
;
}
//class CV_FFmpegWriteSequenceImageTest : public cvtest::BaseTest
//{
// public:
// void run(int)
// {
// try
// {
// const int img_r = 640;
// const int img_c = 480;
// Size frame_s = Size(img_c, img_r);
//
// for (size_t ext = 0; ext < 5; ++ext) // 0 - png, 1 - jpg, 2 - bmp, 3 - pgm, 4 - tiff
// for (size_t k = 1; k <= 3; ++k)
// for (size_t num_channels = 1; num_channels <= 4; ++num_channels)
// for (size_t depth = CV_8U; depth <= CV_16U; ++depth)
// {
// ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", depth, num_channels, ext_from_int(ext).c_str());
// ts->printf(ts->LOG, "creating image\n");
// Mat img(img_r * k, img_c * k, CV_MAKETYPE(depth, num_channels), Scalar::all(0));
// ts->printf(ts->LOG, "drawing circle\n");
// circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
// ts->printf(ts->LOG, "writing image : %s\n", string(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext)).c_str());
// imwrite(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext), img);
// ts->printf(ts->LOG, "reading test image : %s\n", string(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext)).c_str());
// Mat img_test = imread(string(ts->get_data_path()) + "readwrite/test" + ext_from_int(ext));
//
// CV_Assert(img.size() == img_test.size());
// CV_Assert(img.type() == img_test.type());
//
// ts->printf(ts->LOG, "checking test image\n");
// if (countNonZero(img != img_test) != 0)
// ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC);
// }
// }
// catch(...)
// {
// ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
// }
// ts->set_failed_test_info(cvtest::TS::OK);
// }
//};
//TEST(Highgui_FFmpeg_WriteBigImage, regression) { CV_FFmpegWriteBigImageTest test; test.safe_run(); }
//TEST(Highgui_FFmpeg_WriteBigVideo, regression) { CV_FFmpegWriteBigVideoTest test; test.safe_run(); }
class
CV_FFmpegWriteSequenceImageTest
:
public
cvtest
::
BaseTest
{
public:
void
run
(
int
)
{
try
{
const
int
img_r
=
640
;
const
int
img_c
=
480
;
Size
frame_s
=
Size
(
img_c
,
img_r
);
for
(
size_t
k
=
1
;
k
<=
5
;
++
k
)
{
for
(
size_t
ext
=
0
;
ext
<
4
;
++
ext
)
// 0 - png, 1 - bmp, 2 - pgm, 3 - tiff
for
(
size_t
num_channels
=
1
;
num_channels
<=
3
;
num_channels
+=
2
)
{
ts
->
printf
(
ts
->
LOG
,
"image type depth:%d channels:%d ext: %s
\n
"
,
CV_8U
,
num_channels
,
ext_from_int
(
ext
).
c_str
());
Mat
img
(
img_r
*
k
,
img_c
*
k
,
CV_MAKETYPE
(
CV_8U
,
num_channels
),
Scalar
::
all
(
0
));
circle
(
img
,
Point2i
((
img_c
*
k
)
/
2
,
(
img_r
*
k
)
/
2
),
cv
::
min
((
img_r
*
k
),
(
img_c
*
k
))
/
4
,
Scalar
::
all
(
255
));
ts
->
printf
(
ts
->
LOG
,
"writing image : %s
\n
"
,
string
(
string
(
ts
->
get_data_path
())
+
"readwrite/test"
+
ext_from_int
(
ext
)).
c_str
());
imwrite
(
string
(
ts
->
get_data_path
())
+
"readwrite/test"
+
ext_from_int
(
ext
),
img
);
ts
->
printf
(
ts
->
LOG
,
"reading test image : %s
\n
"
,
string
(
string
(
ts
->
get_data_path
())
+
"readwrite/test"
+
ext_from_int
(
ext
)).
c_str
());
Mat
img_test
=
imread
(
string
(
ts
->
get_data_path
())
+
"readwrite/test"
+
ext_from_int
(
ext
),
CV_LOAD_IMAGE_UNCHANGED
);
if
(
img_test
.
empty
())
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
CV_Assert
(
img
.
size
()
==
img_test
.
size
());
CV_Assert
(
img
.
type
()
==
img_test
.
type
());
double
n
=
norm
(
img
,
img_test
);
if
(
n
>
1.0
)
{
ts
->
printf
(
ts
->
LOG
,
"norm = %f
\n
"
,
n
);
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
}
}
for
(
size_t
num_channels
=
1
;
num_channels
<=
3
;
num_channels
+=
2
)
{
// jpeg
ts
->
printf
(
ts
->
LOG
,
"image type depth:%d channels:%d ext: %s
\n
"
,
CV_8U
,
num_channels
,
".jpg"
);
Mat
img
(
img_r
*
k
,
img_c
*
k
,
CV_MAKETYPE
(
CV_8U
,
num_channels
),
Scalar
::
all
(
0
));
circle
(
img
,
Point2i
((
img_c
*
k
)
/
2
,
(
img_r
*
k
)
/
2
),
cv
::
min
((
img_r
*
k
),
(
img_c
*
k
))
/
4
,
Scalar
::
all
(
255
));
string
filename
=
string
(
ts
->
get_data_path
()
+
"readwrite/test_"
+
char
(
k
+
48
)
+
"_c"
+
char
(
num_channels
+
48
)
+
"_.jpg"
);
imwrite
(
filename
,
img
);
img
=
imread
(
filename
,
CV_LOAD_IMAGE_UNCHANGED
);
filename
=
string
(
ts
->
get_data_path
()
+
"readwrite/test_"
+
char
(
k
+
48
)
+
"_c"
+
char
(
num_channels
+
48
)
+
".jpg"
);
ts
->
printf
(
ts
->
LOG
,
"reading test image : %s
\n
"
,
filename
.
c_str
());
Mat
img_test
=
imread
(
filename
,
CV_LOAD_IMAGE_UNCHANGED
);
if
(
img_test
.
empty
())
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
CV_Assert
(
img
.
size
()
==
img_test
.
size
());
CV_Assert
(
img
.
type
()
==
img_test
.
type
());
double
n
=
norm
(
img
,
img_test
);
if
(
n
>
1.0
)
{
ts
->
printf
(
ts
->
LOG
,
"norm = %f
\n
"
,
n
);
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
}
}
for
(
size_t
num_channels
=
1
;
num_channels
<=
3
;
num_channels
+=
2
)
{
// tiff
ts
->
printf
(
ts
->
LOG
,
"image type depth:%d channels:%d ext: %s
\n
"
,
CV_16U
,
num_channels
,
".tiff"
);
Mat
img
(
img_r
*
k
,
img_c
*
k
,
CV_MAKETYPE
(
CV_16U
,
num_channels
),
Scalar
::
all
(
0
));
circle
(
img
,
Point2i
((
img_c
*
k
)
/
2
,
(
img_r
*
k
)
/
2
),
cv
::
min
((
img_r
*
k
),
(
img_c
*
k
))
/
4
,
Scalar
::
all
(
255
));
string
filename
=
string
(
ts
->
get_data_path
()
+
"readwrite/test.tiff"
);
imwrite
(
filename
,
img
);
ts
->
printf
(
ts
->
LOG
,
"reading test image : %s
\n
"
,
filename
.
c_str
());
Mat
img_test
=
imread
(
filename
,
CV_LOAD_IMAGE_UNCHANGED
);
if
(
img_test
.
empty
())
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
CV_Assert
(
img
.
size
()
==
img_test
.
size
());
ts
->
printf
(
ts
->
LOG
,
"img : %d ; %d
\n
"
,
img
.
channels
(),
img
.
depth
());
ts
->
printf
(
ts
->
LOG
,
"img_test : %d ; %d
\n
"
,
img_test
.
channels
(),
img_test
.
depth
());
CV_Assert
(
img
.
type
()
==
img_test
.
type
());
double
n
=
norm
(
img
,
img_test
);
if
(
n
>
1.0
)
{
ts
->
printf
(
ts
->
LOG
,
"norm = %f
\n
"
,
n
);
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
}
}
}
}
catch
(
const
cv
::
Exception
&
e
)
{
ts
->
printf
(
ts
->
LOG
,
"Exception: %s
\n
"
,
e
.
what
());
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
}
}
};
TEST
(
Highgui_FFmpeg_WriteBigImage
,
regression
)
{
CV_FFmpegWriteBigImageTest
test
;
test
.
safe_run
();
}
TEST
(
Highgui_FFmpeg_WriteBigVideo
,
regression
)
{
CV_FFmpegWriteBigVideoTest
test
;
test
.
safe_run
();
}
TEST
(
Highgui_FFmpeg_WriteSequenceImage
,
regression
)
{
CV_FFmpegWriteSequenceImageTest
test
;
test
.
safe_run
();
}
\ No newline at end of file
modules/highgui/test/test_video_io.cpp
浏览文件 @
03c77841
...
...
@@ -69,10 +69,10 @@ double PSNR(const Mat& m1, const Mat& m2)
void
CV_HighGuiTest
::
ImagesTest
(
const
string
&
dir
)
{
string
_name
=
dir
+
string
(
"shared/baboon.jpg"
);
string
_name
=
dir
+
string
(
"
../cv/
shared/baboon.jpg"
);
ts
->
printf
(
ts
->
LOG
,
"reading image : %s
\n
"
,
_name
.
c_str
());
Mat
image
=
imread
(
dir
+
"shared/baboon.jpg"
);
Mat
image
=
imread
(
_name
);
image
.
convertTo
(
image
,
CV_8UC3
);
if
(
image
.
empty
())
...
...
@@ -155,7 +155,7 @@ void CV_HighGuiTest::ImagesTest(const string& dir)
void
CV_HighGuiTest
::
VideoTest
(
const
string
&
dir
,
int
fourcc
)
{
string
src_file
=
dir
+
"shared/video_for_test.avi"
;
string
src_file
=
dir
+
"
../cv/
shared/video_for_test.avi"
;
string
tmp_name
=
dir
+
"video.avi"
;
ts
->
printf
(
ts
->
LOG
,
"reading video : %s
\n
"
,
src_file
.
c_str
());
...
...
@@ -183,7 +183,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
writer
=
cvCreateVideoWriter
(
tmp_name
.
c_str
(),
fourcc
,
24
,
cvGetSize
(
img
));
if
(
writer
==
0
)
{
ts
->
printf
(
ts
->
LOG
,
"can't create writer
\n
"
);
ts
->
printf
(
ts
->
LOG
,
"can't create writer
(with fourcc : %d)
\n
"
,
fourcc
);
cvReleaseCapture
(
&
cap
);
ts
->
set_failed_test_info
(
ts
->
FAIL_MISMATCH
);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录