Use cvtColor() for Bayer image color demosaicing with V4L2_PIX_FMT_SGRBG8#25287
Conversation
|
Looking at the code more closely:
These lines of code do But with
Here we have instead With even To sum-up:
|
8aa6e12 to
ec16cb7
Compare
ec16cb7 to
eaa01f2
Compare
|
@catree go ahead with other cases. |
eaa01f2 to
4061b1d
Compare
|
Now we have the following cases which use
|
4061b1d to
4525060
Compare
|
I'm wondering whether these modes can be added/enabled to our virtual V4L device test: opencv/modules/videoio/test/test_v4l2.cpp Lines 109 to 130 in 99cacaa |
4525060 to
c10d0c2
Compare
|
I have updated the test file. |
|
Could you please also add something like this to the test: diff --git a/modules/videoio/test/test_v4l2.cpp b/modules/videoio/test/test_v4l2.cpp
index 12d2a7210e..5bb1a1f5a3 100644
--- a/modules/videoio/test/test_v4l2.cpp
+++ b/modules/videoio/test/test_v4l2.cpp
@@ -70,6 +70,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 +84,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());
}Currently V4L2 returns a single line in Bayer formats. |
…_SRGGB8, V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SGBRG8, V4L2_PIX_FMT_SGRBG8 options. Update modules/videoio/test/test_v4l2.cpp test file.
c10d0c2 to
d81cd13
Compare


Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
See: #25249
@carabsc Does this change works for you?
If so, I believe it is better to use
cv::cvtColor()function.Warning, this is
GRBG-->BGR.BTW, can we do the same changes with
bayer2rgb24()sgbrg2rgb24()