Skip to content

Commit 962d7ff

Browse files
MediaPipe Teamcopybara-github
authored andcommitted
Utility functions that create RGB images for testing.
PiperOrigin-RevId: 730797962
1 parent b8bd31b commit 962d7ff

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

mediapipe/util/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ cc_library(
494494
"//mediapipe/framework/port:opencv_imgproc",
495495
"//mediapipe/gpu:gpu_buffer",
496496
"//mediapipe/gpu:gpu_buffer_format",
497-
"//mediapipe/gpu:gpu_buffer_storage_image_frame",
498497
"@com_google_absl//absl/log:absl_log",
499498
],
500499
)

mediapipe/util/image_test_utils.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ ImageFrame CreateTestRgba8ImageFrame(int width, int height) {
116116
width, height, /*max_value=*/255.0f);
117117
}
118118

119+
ImageFrame CreateTestRgb8ImageFrame(int width, int height) {
120+
return CreateTestImageFrame<ImageFormat::SRGB, uint8_t>(width, height,
121+
/*max_value=*/255.0f);
122+
}
123+
119124
GpuBuffer CreateTestFloat32GpuBuffer(int width, int height) {
120125
GpuBuffer buffer(width, height, GpuBufferFormat::kGrayFloat32);
121126
std::shared_ptr<ImageFrame> view = buffer.GetWriteView<ImageFrame>();
@@ -137,4 +142,11 @@ GpuBuffer CreateTestRgba8GpuBuffer(int width, int height) {
137142
return buffer;
138143
}
139144

145+
GpuBuffer CreateTestRgb8GpuBuffer(int width, int height) {
146+
GpuBuffer buffer(width, height, GpuBufferFormat::kRGB24);
147+
std::shared_ptr<ImageFrame> view = buffer.GetWriteView<ImageFrame>();
148+
*view = CreateTestRgb8ImageFrame(width, height);
149+
return buffer;
150+
}
151+
140152
} // namespace mediapipe

mediapipe/util/image_test_utils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ ImageFrame CreateTestGrey8ImageFrame(int width, int height);
4141
// Generates 4 channel uint8 RGBA ImageFrame with increasing [0,255] values.
4242
ImageFrame CreateTestRgba8ImageFrame(int width, int height);
4343

44+
// Generates 3 channel uint8 RGB ImageFrame with increasing [0,255] values.
45+
ImageFrame CreateTestRgb8ImageFrame(int width, int height);
46+
4447
// Generates single-channel float32 GpuBuffer with increasing [0,1] values.
4548
GpuBuffer CreateTestFloat32GpuBuffer(int width, int height);
4649

@@ -50,6 +53,9 @@ GpuBuffer CreateTestGrey8GpuBuffer(int width, int height);
5053
// Generates 4 channel uint8 RGBA GpuBuffer with increasing [0,255] values.
5154
GpuBuffer CreateTestRgba8GpuBuffer(int width, int height);
5255

56+
// Generates 3 channel uint8 RGB GpuBuffer with increasing [0,255] values.
57+
GpuBuffer CreateTestRgb8GpuBuffer(int width, int height);
58+
5359
} // namespace mediapipe
5460

5561
#endif // MEDIAPIPE_UTIL_IMAGE_TEST_UTILS_H_

0 commit comments

Comments
 (0)