Skip to content

Commit e59b737

Browse files
authored
Merge pull request #3485 from asmorkalov:as/cuda_codec_get
Promote cv::VideoCapture properties in VideoReader
2 parents 3a2ed1c + d4f7f5f commit e59b737

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

modules/cudacodec/src/ffmpeg_video_source.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,18 @@ void cv::cudacodec::detail::FFmpegVideoSource::updateFormat(const FormatInfo& vi
192192

193193
bool cv::cudacodec::detail::FFmpegVideoSource::get(const int propertyId, double& propertyVal) const
194194
{
195+
propertyVal = cap.get(propertyId);
196+
if (propertyVal != 0.)
197+
return true;
198+
195199
CV_Assert(videoCaptureParams.size() % 2 == 0);
196200
for (std::size_t i = 0; i < videoCaptureParams.size(); i += 2) {
197201
if (videoCaptureParams.at(i) == propertyId) {
198202
propertyVal = videoCaptureParams.at(i + 1);
199203
return true;
200204
}
201205
}
206+
202207
return false;
203208
}
204209

modules/cudacodec/test/test_video.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,19 @@ CUDA_TEST_P(CheckParams, Reader)
430430
}
431431
}
432432

433+
CUDA_TEST_P(CheckParams, CaptureProps)
434+
{
435+
std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "../highgui/video/big_buck_bunny.mp4";
436+
cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile);
437+
double width, height, fps;
438+
ASSERT_TRUE(reader->get(cv::VideoCaptureProperties::CAP_PROP_FRAME_WIDTH, width));
439+
ASSERT_EQ(672, width);
440+
ASSERT_TRUE(reader->get(cv::VideoCaptureProperties::CAP_PROP_FRAME_HEIGHT, height));
441+
ASSERT_EQ(384, height);
442+
ASSERT_TRUE(reader->get(cv::VideoCaptureProperties::CAP_PROP_FPS, fps));
443+
ASSERT_EQ(24, fps);
444+
}
445+
433446
CUDA_TEST_P(CheckDecodeSurfaces, Reader)
434447
{
435448
cv::cuda::setDevice(GET_PARAM(0).deviceID());
@@ -554,6 +567,7 @@ CUDA_TEST_P(TransCode, H264ToH265)
554567
}
555568

556569
INSTANTIATE_TEST_CASE_P(CUDA_Codec, TransCode, ALL_DEVICES);
570+
557571
#endif
558572

559573
#if defined(HAVE_NVCUVENC)

0 commit comments

Comments
 (0)