1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #19394 from MaximMilashchenko:params

add video capture parameters

* add parameters

* videoio: revert unnecessary massive changes

* videoio: support capture parameters in backends API

- add tests
- FFmpeg backend sample code
- StaticBackend API is done
- support through PluginBackend API will be added later

Co-authored-by: Milashchenko <maksim.milashchenko@intel.com>
Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
This commit is contained in:
MaximMilashchenko
2021-01-28 01:07:43 +03:00
committed by GitHub
parent 37c12db366
commit 467870415b
10 changed files with 428 additions and 30 deletions
+59
View File
@@ -459,4 +459,63 @@ TEST(videoio, mp4_orientation_no_rotation)
ASSERT_EQ(384, frame.rows);
}
static void ffmpeg_check_read_raw(VideoCapture& cap)
{
ASSERT_TRUE(cap.isOpened()) << "Can't open the video";
Mat data;
cap >> data;
EXPECT_EQ(CV_8UC1, data.type()) << "CV_8UC1 != " << typeToString(data.type());
EXPECT_TRUE(data.rows == 1 || data.cols == 1) << data.size;
EXPECT_EQ((size_t)29729, data.total());
cap >> data;
EXPECT_EQ(CV_8UC1, data.type()) << "CV_8UC1 != " << typeToString(data.type());
EXPECT_TRUE(data.rows == 1 || data.cols == 1) << data.size;
EXPECT_EQ((size_t)37118, data.total());
}
TEST(videoio_ffmpeg, open_with_property)
{
if (!videoio_registry::hasBackend(CAP_FFMPEG))
throw SkipTestException("FFmpeg backend was not found");
string video_file = findDataFile("video/big_buck_bunny.mp4");
VideoCapture cap;
EXPECT_NO_THROW(cap.open(video_file, CAP_FFMPEG, {
CAP_PROP_FORMAT, -1 // demux only
}));
ffmpeg_check_read_raw(cap);
}
TEST(videoio_ffmpeg, create_with_property)
{
if (!videoio_registry::hasBackend(CAP_FFMPEG))
throw SkipTestException("FFmpeg backend was not found");
string video_file = findDataFile("video/big_buck_bunny.mp4");
VideoCapture cap(video_file, CAP_FFMPEG, {
CAP_PROP_FORMAT, -1 // demux only
});
ffmpeg_check_read_raw(cap);
}
TEST(videoio_ffmpeg, create_with_property_badarg)
{
if (!videoio_registry::hasBackend(CAP_FFMPEG))
throw SkipTestException("FFmpeg backend was not found");
string video_file = findDataFile("video/big_buck_bunny.mp4");
EXPECT_ANY_THROW(
{
VideoCapture cap(video_file, CAP_FFMPEG, {
CAP_PROP_FORMAT, -2 // invalid
});
});
}
}} // namespace