Merge pull request #3485 from asmorkalov:as/cuda_codec_get

Promote cv::VideoCapture properties in VideoReader
pull/3495/head
Alexander Smorkalov 2 years ago committed by GitHub
commit e59b737b9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      modules/cudacodec/src/ffmpeg_video_source.cpp
  2. 14
      modules/cudacodec/test/test_video.cpp

@ -192,6 +192,10 @@ void cv::cudacodec::detail::FFmpegVideoSource::updateFormat(const FormatInfo& vi
bool cv::cudacodec::detail::FFmpegVideoSource::get(const int propertyId, double& propertyVal) const 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); CV_Assert(videoCaptureParams.size() % 2 == 0);
for (std::size_t i = 0; i < videoCaptureParams.size(); i += 2) { for (std::size_t i = 0; i < videoCaptureParams.size(); i += 2) {
if (videoCaptureParams.at(i) == propertyId) { if (videoCaptureParams.at(i) == propertyId) {
@ -199,6 +203,7 @@ bool cv::cudacodec::detail::FFmpegVideoSource::get(const int propertyId, double&
return true; return true;
} }
} }
return false; return false;
} }

@ -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) CUDA_TEST_P(CheckDecodeSurfaces, Reader)
{ {
cv::cuda::setDevice(GET_PARAM(0).deviceID()); cv::cuda::setDevice(GET_PARAM(0).deviceID());
@ -554,6 +567,7 @@ CUDA_TEST_P(TransCode, H264ToH265)
} }
INSTANTIATE_TEST_CASE_P(CUDA_Codec, TransCode, ALL_DEVICES); INSTANTIATE_TEST_CASE_P(CUDA_Codec, TransCode, ALL_DEVICES);
#endif #endif
#if defined(HAVE_NVCUVENC) #if defined(HAVE_NVCUVENC)

Loading…
Cancel
Save