Skip to content

Commit

Permalink
Promote cv::VideoCapture properties in VideoReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
asmorkalov committed May 3, 2023
1 parent 960b3f6 commit d4f7f5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/cudacodec/src/ffmpeg_video_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,18 @@ void cv::cudacodec::detail::FFmpegVideoSource::updateFormat(const FormatInfo& vi

bool cv::cudacodec::detail::FFmpegVideoSource::get(const int propertyId, double& propertyVal) const
{
propertyVal = cap.get(propertyId);
if (propertyVal != 0.)
return true;

CV_Assert(videoCaptureParams.size() % 2 == 0);
for (std::size_t i = 0; i < videoCaptureParams.size(); i += 2) {
if (videoCaptureParams.at(i) == propertyId) {
propertyVal = videoCaptureParams.at(i + 1);
return true;
}
}

return false;
}

Expand Down
14 changes: 14 additions & 0 deletions modules/cudacodec/test/test_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,19 @@ CUDA_TEST_P(CheckParams, Reader)
}
}

CUDA_TEST_P(CheckParams, CaptureProps)
{
std::string inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "../highgui/video/big_buck_bunny.mp4";
cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile);
double width, height, fps;
ASSERT_TRUE(reader->get(cv::VideoCaptureProperties::CAP_PROP_FRAME_WIDTH, width));
ASSERT_EQ(672, width);
ASSERT_TRUE(reader->get(cv::VideoCaptureProperties::CAP_PROP_FRAME_HEIGHT, height));
ASSERT_EQ(384, height);
ASSERT_TRUE(reader->get(cv::VideoCaptureProperties::CAP_PROP_FPS, fps));
ASSERT_EQ(24, fps);
}

CUDA_TEST_P(CheckDecodeSurfaces, Reader)
{
cv::cuda::setDevice(GET_PARAM(0).deviceID());
Expand Down Expand Up @@ -554,6 +567,7 @@ CUDA_TEST_P(TransCode, H264ToH265)
}

INSTANTIATE_TEST_CASE_P(CUDA_Codec, TransCode, ALL_DEVICES);

#endif

#if defined(HAVE_NVCUVENC)
Expand Down

0 comments on commit d4f7f5f

Please sign in to comment.