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

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2024-04-10 10:38:58 +03:00
32 changed files with 2897 additions and 432 deletions
+26 -4
View File
@@ -17,6 +17,8 @@
#ifdef HAVE_CAMV4L2
// #define DUMP_CAMERA_FRAME
#include "test_precomp.hpp"
#include <opencv2/core/utils/configuration.private.hpp>
#include <linux/videodev2.h>
@@ -70,6 +72,7 @@ TEST_P(videoio_v4l2, formats)
const string device = devs[0];
const Size sz(640, 480);
const Format_Channels_Depth params = GetParam();
const Size esz(sz.width * params.mul_width, sz.height * params.mul_height);
{
// Case with RAW output
@@ -83,7 +86,17 @@ TEST_P(videoio_v4l2, formats)
Mat img;
EXPECT_TRUE(cap.grab());
EXPECT_TRUE(cap.retrieve(img));
EXPECT_EQ(Size(sz.width * params.mul_width, sz.height * params.mul_height), img.size());
if (params.pixel_format == V4L2_PIX_FMT_SRGGB8 ||
params.pixel_format == V4L2_PIX_FMT_SBGGR8 ||
params.pixel_format == V4L2_PIX_FMT_SGBRG8 ||
params.pixel_format == V4L2_PIX_FMT_SGRBG8)
{
EXPECT_EQ((size_t)esz.area(), img.total());
}
else
{
EXPECT_EQ(esz, img.size());
}
EXPECT_EQ(params.channels, img.channels());
EXPECT_EQ(params.depth, img.depth());
}
@@ -102,6 +115,13 @@ TEST_P(videoio_v4l2, formats)
EXPECT_EQ(sz, img.size());
EXPECT_EQ(3, img.channels());
EXPECT_EQ(CV_8U, img.depth());
#ifdef DUMP_CAMERA_FRAME
std::string img_name = "frame_" + fourccToString(params.pixel_format);
// V4L2 flag for big-endian formats
if(params.pixel_format & (1 << 31))
img_name += "-BE";
cv::imwrite(img_name + ".png", img);
#endif
}
}
}
@@ -116,9 +136,11 @@ vector<Format_Channels_Depth> all_params = {
// { V4L2_PIX_FMT_JPEG, 1, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_YUYV, 2, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_UYVY, 2, CV_8U, 1.f, 1.f },
// { V4L2_PIX_FMT_SBGGR8, 1, CV_8U, 1.f, 1.f },
// { V4L2_PIX_FMT_SN9C10X, 3, CV_8U, 1.f, 1.f },
// { V4L2_PIX_FMT_SGBRG8, 1, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_SN9C10X, 3, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_SRGGB8, 1, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_SBGGR8, 1, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_SGBRG8, 1, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_SGRBG8, 1, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_RGB24, 3, CV_8U, 1.f, 1.f },
{ V4L2_PIX_FMT_Y16, 1, CV_16U, 1.f, 1.f },
{ V4L2_PIX_FMT_Y16_BE, 1, CV_16U, 1.f, 1.f },