mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 20:42:53 +08:00
Merge pull request #24240 from asmorkalov:as/vl4_convert_rgb
Added test with V4L CAP_PROP_CONVERT_RGB=false.
This commit is contained in:
commit
2f63c58380
@ -223,6 +223,35 @@ TEST(DISABLED_videoio_camera, v4l_read_framesize)
|
|||||||
capture.release();
|
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
|
static
|
||||||
utils::Paths getTestCameras()
|
utils::Paths getTestCameras()
|
||||||
|
Loading…
Reference in New Issue
Block a user