Merge pull request #24240 from asmorkalov:as/vl4_convert_rgb

Added test with V4L CAP_PROP_CONVERT_RGB=false.
pull/24416/head^2
Alexander Smorkalov 1 year ago committed by GitHub
commit 2f63c58380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      modules/videoio/test/test_camera.cpp

@ -223,6 +223,35 @@ TEST(DISABLED_videoio_camera, v4l_read_framesize)
capture.release();
}
TEST(DISABLED_videoio_camera, v4l_rgb_convert)
{
VideoCapture capture(CAP_V4L2);
ASSERT_TRUE(capture.isOpened());
std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
std::cout << " Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
std::cout << "Pixel format: " << capture.get(cv::CAP_PROP_FORMAT) << std::endl;
if (capture.get(CAP_PROP_FOURCC) != VideoWriter::fourcc('Y', 'U', 'Y', 'V'))
{
throw SkipTestException("Camera does not support YUYV format");
}
capture.set(cv::CAP_PROP_CONVERT_RGB, 0);
std::cout << "New pixel format: " << capture.get(cv::CAP_PROP_FORMAT) << std::endl;
cv::Mat frame;
for (int i = 0; i < 10; i++)
{
int pixel_type = (int)capture.get(cv::CAP_PROP_FORMAT);
int channels = CV_MAT_CN(pixel_type);
int pixel_bytes = CV_ELEM_SIZE(pixel_type);
// YUYV is expected for most of popular USB cam (COLOR_YUV2BGR_YUYV conversion)
EXPECT_EQ(2, channels);
EXPECT_EQ(2, pixel_bytes);
capture >> frame;
}
}
static
utils::Paths getTestCameras()

Loading…
Cancel
Save