Skip to content

Commit 933c340

Browse files
Mayank Jainmeta-codesync[bot]
authored andcommitted
Add Bayer8 BGGR Pixel Format in VRS
Summary: Recent RGB Camera (Alberta) generates raw image in BGGR format, hence the change. Differential Revision: D97062899 fbshipit-source-id: 11522e2ab9603330fe8dd3368997911b1ad6a9d7
1 parent 7a9d860 commit 933c340

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

vrs/RecordFormat.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ static_assert(static_cast<int>(ImageFormat::JXL) == 5, "ImageFormat enum values
8484

8585
// These text names may NEVER BE CHANGED, as they are used in data layout definitions!!
8686
string_view sPixelFormatNames[] = {
87-
"undefined", "grey8", "bgr8", "depth32f", "rgb8",
88-
"yuv_i420_split", "rgba8", "rgb10", "rgb12", "grey10",
89-
"grey12", "grey16", "rgb32F", "scalar64F", "yuy2",
90-
"rgb_ir_4x4", "rgba32F", "bayer8_rggb", "raw10", "raw10_bayer_rggb",
91-
"raw10_bayer_bggr", "yuv_420_nv21", "yuv_420_nv12", "grey10packed"};
87+
"undefined", "grey8", "bgr8", "depth32f", "rgb8",
88+
"yuv_i420_split", "rgba8", "rgb10", "rgb12", "grey10",
89+
"grey12", "grey16", "rgb32F", "scalar64F", "yuy2",
90+
"rgb_ir_4x4", "rgba32F", "bayer8_rggb", "raw10", "raw10_bayer_rggb",
91+
"raw10_bayer_bggr", "yuv_420_nv21", "yuv_420_nv12", "grey10packed", "bayer8_bggr"};
9292
ENUM_STRING_CONVERTER(PixelFormat, sPixelFormatNames, PixelFormat::UNDEFINED);
9393

9494
// Enum values may NEVER BE CHANGED, as they are used in data layout definitions!!
@@ -476,6 +476,7 @@ uint8_t ImageContentBlockSpec::getChannelCountPerPixel(PixelFormat pixel) {
476476
case PixelFormat::DEPTH32F:
477477
case PixelFormat::SCALAR64F:
478478
case PixelFormat::BAYER8_RGGB:
479+
case PixelFormat::BAYER8_BGGR:
479480
case PixelFormat::RAW10_BAYER_RGGB:
480481
case PixelFormat::RAW10_BAYER_BGGR:
481482
case PixelFormat::RAW10:
@@ -511,6 +512,7 @@ size_t ImageContentBlockSpec::getBytesPerPixel(PixelFormat pixel) {
511512
case PixelFormat::GREY8:
512513
case PixelFormat::RGB_IR_RAW_4X4:
513514
case PixelFormat::BAYER8_RGGB:
515+
case PixelFormat::BAYER8_BGGR:
514516
return 1;
515517
case PixelFormat::GREY10:
516518
case PixelFormat::GREY12:

vrs/RecordFormat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ enum class PixelFormat : uint8_t {
8888
YUV_420_NV21, ///< Y plane + half width/half height chroma plane with weaved V and U values.
8989
YUV_420_NV12, ///< Y plane + half width/half height chroma plane with weaved U and V values.
9090
GREY10PACKED, ///< 10 bit per pixel, packed in successive little-endian bits, in 40 bits blocks.
91+
BAYER8_BGGR, ///< 8 bit per pixel, BGGR bayer pattern.
9192

9293
COUNT, ///< Count of values in this enum type. @internal
9394
};
1.96 KB
Binary file not shown.

vrs/utils/PixelFrame.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ PixelFormat PixelFrame::getNormalizedPixelFormat(
455455
sourcePixelFormat == PixelFormat::GREY16) {
456456
format = PixelFormat::RGB8;
457457
#if IS_VRS_FB_INTERNAL()
458-
} else if (format == PixelFormat::BAYER8_RGGB) {
458+
} else if (format == PixelFormat::BAYER8_RGGB || format == PixelFormat::BAYER8_BGGR) {
459459
format = PixelFormat::RGB8;
460460
#endif
461461
} else {
@@ -668,6 +668,7 @@ bool PixelFrame::normalizeFrame(
668668
case PixelFormat::DEPTH32F:
669669
case PixelFormat::SCALAR64F:
670670
case PixelFormat::BAYER8_RGGB:
671+
case PixelFormat::BAYER8_BGGR:
671672
format = PixelFormat::GREY8;
672673
componentCount = 1;
673674
break;
@@ -724,7 +725,7 @@ bool PixelFrame::normalizeFrame(
724725
} else if (srcFormat == PixelFormat::SCALAR64F) {
725726
// normalize double pixels to grey8
726727
normalizeBuffer<double>(rdata(), outNormalizedFrame.wdata(), getWidth() * getHeight());
727-
} else if (srcFormat == PixelFormat::BAYER8_RGGB) {
728+
} else if (srcFormat == PixelFormat::BAYER8_RGGB || srcFormat == PixelFormat::BAYER8_BGGR) {
728729
// display as grey8(copy) for now
729730
const uint8_t* srcPtr = rdata();
730731
uint8_t* outPtr = outNormalizedFrame.wdata();

vrs/utils/test/FilteredFileReaderTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ TEST_F(FilteredFileReaderTest, includeExcludeStreams) {
115115
filters.includeStream("214");
116116
filters.excludeStream("100-test/synthetic/raw10");
117117
filteredReader.applyFilters(filters);
118-
EXPECT_EQ(filteredReader.filter.streams.size(), 19);
118+
EXPECT_EQ(filteredReader.filter.streams.size(), 20);
119119
}
120120
}

0 commit comments

Comments
 (0)