mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -333,4 +333,70 @@ TEST(videoio_ffmpeg, parallel)
|
||||
}
|
||||
}
|
||||
|
||||
typedef std::pair<VideoCaptureProperties, double> cap_property_t;
|
||||
typedef std::vector<cap_property_t> cap_properties_t;
|
||||
typedef std::pair<std::string, cap_properties_t> ffmpeg_cap_properties_param_t;
|
||||
typedef testing::TestWithParam<ffmpeg_cap_properties_param_t> ffmpeg_cap_properties;
|
||||
|
||||
#ifdef _WIN32
|
||||
namespace {
|
||||
::testing::AssertionResult IsOneOf(double value, double expected1, double expected2)
|
||||
{
|
||||
// internal floating point class is used to perform accurate floating point types comparison
|
||||
typedef ::testing::internal::FloatingPoint<double> FloatingPoint;
|
||||
|
||||
FloatingPoint val(value);
|
||||
if (val.AlmostEquals(FloatingPoint(expected1)) || val.AlmostEquals(FloatingPoint(expected2)))
|
||||
{
|
||||
return ::testing::AssertionSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ::testing::AssertionFailure()
|
||||
<< value << " is neither equal to " << expected1 << " nor " << expected2;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_P(ffmpeg_cap_properties, can_read_property)
|
||||
{
|
||||
if (!videoio_registry::hasBackend(CAP_FFMPEG))
|
||||
throw SkipTestException("FFmpeg backend was not found");
|
||||
|
||||
ffmpeg_cap_properties_param_t parameters = GetParam();
|
||||
const std::string path = parameters.first;
|
||||
const cap_properties_t properties = parameters.second;
|
||||
|
||||
VideoCapture cap(findDataFile(path), CAP_FFMPEG);
|
||||
ASSERT_TRUE(cap.isOpened()) << "Can not open " << findDataFile(path);
|
||||
|
||||
for (std::size_t i = 0; i < properties.size(); ++i)
|
||||
{
|
||||
const cap_property_t& prop = properties[i];
|
||||
const double actualValue = cap.get(static_cast<int>(prop.first));
|
||||
#ifndef _WIN32
|
||||
EXPECT_DOUBLE_EQ(actualValue, prop.second)
|
||||
<< "Property " << static_cast<int>(prop.first) << " has wrong value";
|
||||
#else
|
||||
EXPECT_TRUE(IsOneOf(actualValue, prop.second, 0.0))
|
||||
<< "Property " << static_cast<int>(prop.first) << " has wrong value";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
cap_properties_t loadBigBuckBunnyFFProbeResults() {
|
||||
cap_property_t properties[] = { cap_property_t(CAP_PROP_BITRATE, 5851.),
|
||||
cap_property_t(CAP_PROP_FPS, 24.),
|
||||
cap_property_t(CAP_PROP_FRAME_HEIGHT, 384.),
|
||||
cap_property_t(CAP_PROP_FRAME_WIDTH, 672.) };
|
||||
return cap_properties_t(properties, properties + sizeof(properties) / sizeof(cap_property_t));
|
||||
}
|
||||
|
||||
const ffmpeg_cap_properties_param_t videoio_ffmpeg_properties[] = {
|
||||
ffmpeg_cap_properties_param_t("video/big_buck_bunny.avi", loadBigBuckBunnyFFProbeResults())
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(videoio, ffmpeg_cap_properties, testing::ValuesIn(videoio_ffmpeg_properties));
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user