Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv_contrib
提交
9c10a6d8
O
opencv_contrib
项目概览
OpenCV
/
opencv_contrib
9 个月 前同步成功
通知
750
Star
8664
Fork
5663
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv_contrib
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
9c10a6d8
编写于
6月 22, 2023
作者:
A
Alexander Smorkalov
提交者:
GitHub
6月 22, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3488 from cudawarped:fix_cudacodec_codec_resolution
`cudacodec::VideoReader` FORCC update with main #23540
上级
813967b5
72080b89
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
18 deletion
+49
-18
modules/cudacodec/src/ffmpeg_video_source.cpp
modules/cudacodec/src/ffmpeg_video_source.cpp
+29
-3
modules/cudacodec/test/test_video.cpp
modules/cudacodec/test/test_video.cpp
+20
-15
未找到文件。
modules/cudacodec/src/ffmpeg_video_source.cpp
浏览文件 @
9c10a6d8
...
@@ -66,8 +66,10 @@ static std::string fourccToString(int fourcc)
...
@@ -66,8 +66,10 @@ static std::string fourccToString(int fourcc)
(
i32_c
.
c
[
3
]
>=
' '
&&
i32_c
.
c
[
3
]
<
128
)
?
i32_c
.
c
[
3
]
:
'?'
);
(
i32_c
.
c
[
3
]
>=
' '
&&
i32_c
.
c
[
3
]
<
128
)
?
i32_c
.
c
[
3
]
:
'?'
);
}
}
// handle old FFmpeg backend - remove when windows shared library is updated
#ifdef _WIN32
static
static
Codec
FourccToCodec
(
int
codec
)
Codec
FourccToCodec
Win32Old
(
int
codec
)
{
{
switch
(
codec
)
switch
(
codec
)
{
{
...
@@ -100,9 +102,34 @@ Codec FourccToCodec(int codec)
...
@@ -100,9 +102,34 @@ Codec FourccToCodec(int codec)
case
CV_FOURCC_MACRO
(
'a'
,
'v'
,
'0'
,
'1'
):
// fallthru
case
CV_FOURCC_MACRO
(
'a'
,
'v'
,
'0'
,
'1'
):
// fallthru
case
CV_FOURCC_MACRO
(
'A'
,
'V'
,
'0'
,
'1'
):
return
AV1
;
case
CV_FOURCC_MACRO
(
'A'
,
'V'
,
'0'
,
'1'
):
return
AV1
;
default:
default:
break
;
return
NumCodecs
;
}
}
}
#endif
static
Codec
FourccToCodec
(
int
codec
)
{
#ifdef _WIN32 // handle old FFmpeg backend - remove when windows shared library is updated
Codec
win32OldCodec
=
FourccToCodecWin32Old
(
codec
);
if
(
win32OldCodec
!=
NumCodecs
)
return
win32OldCodec
;
#endif
switch
(
codec
)
{
case
CV_FOURCC_MACRO
(
'm'
,
'p'
,
'g'
,
'1'
):
return
MPEG1
;
case
CV_FOURCC_MACRO
(
'm'
,
'p'
,
'g'
,
'2'
):
return
MPEG2
;
case
CV_FOURCC_MACRO
(
'F'
,
'M'
,
'P'
,
'4'
):
return
MPEG4
;
case
CV_FOURCC_MACRO
(
'W'
,
'V'
,
'C'
,
'1'
):
return
VC1
;
case
CV_FOURCC_MACRO
(
'h'
,
'2'
,
'6'
,
'4'
):
return
H264
;
case
CV_FOURCC_MACRO
(
'h'
,
'e'
,
'v'
,
'c'
):
return
HEVC
;
case
CV_FOURCC_MACRO
(
'M'
,
'J'
,
'P'
,
'G'
):
return
JPEG
;
case
CV_FOURCC_MACRO
(
'V'
,
'P'
,
'8'
,
'0'
):
return
VP8
;
case
CV_FOURCC_MACRO
(
'V'
,
'P'
,
'9'
,
'0'
):
return
VP9
;
case
CV_FOURCC_MACRO
(
'A'
,
'V'
,
'0'
,
'1'
):
return
AV1
;
default:
break
;
}
std
::
string
msg
=
cv
::
format
(
"Unknown codec FOURCC: 0x%08X (%s)"
,
codec
,
fourccToString
(
codec
).
c_str
());
std
::
string
msg
=
cv
::
format
(
"Unknown codec FOURCC: 0x%08X (%s)"
,
codec
,
fourccToString
(
codec
).
c_str
());
CV_LOG_WARNING
(
NULL
,
msg
);
CV_LOG_WARNING
(
NULL
,
msg
);
CV_Error
(
Error
::
StsUnsupportedFormat
,
msg
);
CV_Error
(
Error
::
StsUnsupportedFormat
,
msg
);
...
@@ -163,7 +190,6 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname,
...
@@ -163,7 +190,6 @@ cv::cudacodec::detail::FFmpegVideoSource::FFmpegVideoSource(const String& fname,
int
codec
=
(
int
)
cap
.
get
(
CAP_PROP_FOURCC
);
int
codec
=
(
int
)
cap
.
get
(
CAP_PROP_FOURCC
);
int
pixelFormat
=
(
int
)
cap
.
get
(
CAP_PROP_CODEC_PIXEL_FORMAT
);
int
pixelFormat
=
(
int
)
cap
.
get
(
CAP_PROP_CODEC_PIXEL_FORMAT
);
format_
.
codec
=
FourccToCodec
(
codec
);
format_
.
codec
=
FourccToCodec
(
codec
);
format_
.
height
=
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
);
format_
.
height
=
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
);
format_
.
width
=
cap
.
get
(
CAP_PROP_FRAME_WIDTH
);
format_
.
width
=
cap
.
get
(
CAP_PROP_FRAME_WIDTH
);
...
...
modules/cudacodec/test/test_video.cpp
浏览文件 @
9c10a6d8
...
@@ -281,15 +281,11 @@ CUDA_TEST_P(DisplayResolution, Reader)
...
@@ -281,15 +281,11 @@ CUDA_TEST_P(DisplayResolution, Reader)
CUDA_TEST_P
(
Video
,
Reader
)
CUDA_TEST_P
(
Video
,
Reader
)
{
{
cv
::
cuda
::
setDevice
(
GET_PARAM
(
0
).
deviceID
());
cv
::
cuda
::
setDevice
(
GET_PARAM
(
0
).
deviceID
());
const
std
::
string
relativeFilePath
=
GET_PARAM
(
1
);
// CUDA demuxer has to fall back to ffmpeg to process "cv/video/768x576.avi"
// CUDA demuxer has to fall back to ffmpeg to process "cv/video/768x576.avi"
if
(
GET_PARAM
(
1
)
==
"cv/video/768x576.avi"
&&
!
videoio_registry
::
hasBackend
(
CAP_FFMPEG
))
if
(
relativeFilePath
==
"cv/video/768x576.avi"
&&
!
videoio_registry
::
hasBackend
(
CAP_FFMPEG
))
throw
SkipTestException
(
"FFmpeg backend not found"
);
throw
SkipTestException
(
"FFmpeg backend not found - SKIP"
);
#ifdef _WIN32 // handle old FFmpeg backend
if
(
GET_PARAM
(
1
)
==
"/cv/tracking/faceocc2/data/faceocc2.webm"
)
throw
SkipTestException
(
"Feature not yet supported by Windows FFmpeg shared library!"
);
#endif
const
std
::
vector
<
std
::
pair
<
cudacodec
::
ColorFormat
,
int
>>
formatsToChannels
=
{
const
std
::
vector
<
std
::
pair
<
cudacodec
::
ColorFormat
,
int
>>
formatsToChannels
=
{
{
cudacodec
::
ColorFormat
::
GRAY
,
1
},
{
cudacodec
::
ColorFormat
::
GRAY
,
1
},
...
@@ -298,7 +294,7 @@ CUDA_TEST_P(Video, Reader)
...
@@ -298,7 +294,7 @@ CUDA_TEST_P(Video, Reader)
{
cudacodec
::
ColorFormat
::
NV_NV12
,
1
}
{
cudacodec
::
ColorFormat
::
NV_NV12
,
1
}
};
};
std
::
string
inputFile
=
std
::
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"../"
+
GET_PARAM
(
1
)
;
std
::
string
inputFile
=
std
::
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"../"
+
relativeFilePath
;
cv
::
Ptr
<
cv
::
cudacodec
::
VideoReader
>
reader
=
cv
::
cudacodec
::
createVideoReader
(
inputFile
);
cv
::
Ptr
<
cv
::
cudacodec
::
VideoReader
>
reader
=
cv
::
cudacodec
::
createVideoReader
(
inputFile
);
ASSERT_FALSE
(
reader
->
set
(
cudacodec
::
ColorFormat
::
RGB
));
ASSERT_FALSE
(
reader
->
set
(
cudacodec
::
ColorFormat
::
RGB
));
cv
::
cudacodec
::
FormatInfo
fmt
=
reader
->
format
();
cv
::
cudacodec
::
FormatInfo
fmt
=
reader
->
format
();
...
@@ -818,13 +814,20 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, Scaling, testing::Combine(
...
@@ -818,13 +814,20 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, Scaling, testing::Combine(
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
DisplayResolution
,
ALL_DEVICES
);
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
DisplayResolution
,
ALL_DEVICES
);
#define VIDEO_SRC_R "highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
#ifdef _WIN32 // handle old FFmpeg backend - remove when windows shared library is updated
#define VIDEO_SRC_R testing::Values("highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \
"highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4", "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4", \
"highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4")
"cv/tracking/faceocc2/data/faceocc2.webm"
//, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4", \
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
Video
,
testing
::
Combine
(
"cv/tracking/faceocc2/data/faceocc2.webm"
)
ALL_DEVICES
,
#else
testing
::
Values
(
VIDEO_SRC_R
)));
#define VIDEO_SRC_R testing::Values("highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg", \
"highgui/video/sample_322x242_15frames.yuv420p.libvpx-vp9.mp4")
//, "highgui/video/sample_322x242_15frames.yuv420p.libaom-av1.mp4", \
"cv/tracking/faceocc2/data/faceocc2.webm"
,
"highgui/video/sample_322x242_15frames.yuv420p.mpeg2video.mp4"
,
"highgui/video/sample_322x242_15frames.yuv420p.mjpeg.mp4"
)
#endif
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
Video
,
testing
::
Combine
(
ALL_DEVICES
,
VIDEO_SRC_R
));
const
color_conversion_params_t
color_conversion_params
[]
=
const
color_conversion_params_t
color_conversion_params
[]
=
{
{
...
@@ -859,9 +862,11 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckExtraData, testing::Combine(
...
@@ -859,9 +862,11 @@ INSTANTIATE_TEST_CASE_P(CUDA_Codec, CheckExtraData, testing::Combine(
ALL_DEVICES
,
ALL_DEVICES
,
testing
::
ValuesIn
(
check_extra_data_params
)));
testing
::
ValuesIn
(
check_extra_data_params
)));
#define VIDEO_SRC_KEY "highgui/video/big_buck_bunny.mp4", "cv/video/768x576.avi", "cv/video/1920x1080.avi", "highgui/video/big_buck_bunny.avi", \
"highgui/video/big_buck_bunny.h264", "highgui/video/big_buck_bunny.h265", "highgui/video/big_buck_bunny.mpg"
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
CheckKeyFrame
,
testing
::
Combine
(
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
CheckKeyFrame
,
testing
::
Combine
(
ALL_DEVICES
,
ALL_DEVICES
,
testing
::
Values
(
VIDEO_SRC_
R
)));
testing
::
Values
(
VIDEO_SRC_
KEY
)));
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
CheckParams
,
ALL_DEVICES
);
INSTANTIATE_TEST_CASE_P
(
CUDA_Codec
,
CheckParams
,
ALL_DEVICES
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录