Skip to content

Commit 763d3d6

Browse files
Merge remote-tracking branch 'gitlab/master'
2 parents f061a1e + 5b3c65d commit 763d3d6

File tree

5 files changed

+68
-75
lines changed

5 files changed

+68
-75
lines changed

.github/workflows/develop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
shell: bash
4141
run: |
4242
mkdir ${HOME}/halide
43-
curl -L curl -L http://ion-archives.s3-us-west-2.amazonaws.com/genesis-runtime/Halide-12.0.1-x86-64-ubuntu-18.04.tar.gz | tar zx -C ${HOME}/halide --strip-components 1
43+
curl -L http://ion-archives.s3-us-west-2.amazonaws.com/genesis-runtime/Halide-12.0.1-x86-64-ubuntu-18.04.tar.gz | tar zx -C ${HOME}/halide --strip-components 1
4444
find ${HOME}/halide -type d | xargs chmod 755
4545
sudo cp -r ${HOME}/halide/* /usr/
4646

example/u3v.cc

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path,
3333
Port wp{ "width", Halide::type_of<int32_t>() };
3434
Port hp{ "height", Halide::type_of<int32_t>() };
3535

36+
Port r_gain0_p{"r_gain0", Halide::type_of<float>()};
37+
Port g_gain0_p{"g_gain0", Halide::type_of<float>()};
38+
Port b_gain0_p{"b_gain0", Halide::type_of<float>()};
39+
40+
Port r_gain1_p{"r_gain1", Halide::type_of<float>()};
41+
Port g_gain1_p{"g_gain1", Halide::type_of<float>()};
42+
Port b_gain1_p{"b_gain1", Halide::type_of<float>()};
43+
44+
3645
// obtain sensor images
3746
auto n = b.add("u3v_camera")(gain0_p, gain1_p, exposure0_p, exposure1_p)
3847
.set_param(
@@ -51,15 +60,48 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path,
5160
Param{"fps", "60.0"});
5261
Port terminator = n["output"];
5362

54-
// TODO replace the following section (bayer2BGR)
55-
// with the exisiting BBs
56-
n = b.add("image_io_bayer2bgr")(lp, wp, hp);
57-
lp = n["output"];
58-
n = b.add("image_io_bayer2bgr")(rp, wp, hp);
59-
rp = n["output"];
60-
n = b.add("core_reorder_buffer_3d_uint8")(lp).set_param(Param{"dim0", "1"}, Param{"dim1", "2"}, Param{"dim2", "0"});
63+
/* image processing on the iamge obtained from the left sensor */
64+
n = b.add("image_processing_normalize_raw_image")(lp).set_param(Param{"bit_width", "12"}, Param{"bit_shift", "0"});
65+
n = b.add("image_processing_bayer_white_balance")(r_gain0_p, g_gain0_p, b_gain0_p, n["output"]).set_param(Param{"bayer_pattern", "GBRG"});
66+
n = b.add("image_processing_bayer_demosaic_simple")(n["output"]).set_param(
67+
Param{"bayer_pattern", "GBRG"},
68+
Param{"width", std::to_string(width)},
69+
Param{"height", std::to_string(height)}
70+
);
71+
n = b.add("image_processing_resize_bilinear_3d")(n["output"]).set_param(
72+
Param{"width", std::to_string(width)},
73+
Param{"height", std::to_string(height)},
74+
Param{"scale", std::to_string(2.0f)}
75+
);
76+
n = b.add("core_denormalize_3d_uint8")(n["output"]);
77+
n = b.add("image_processing_crop_image_3d_uint8")(n["output"]).set_param(
78+
Param{"input_width", std::to_string(width)},
79+
Param{"input_height", std::to_string(height)},
80+
Param{"output_width", std::to_string(width)},
81+
Param{"output_height", std::to_string(height)}
82+
); /*optional*/
6183
lp = n["output"];
62-
n = b.add("core_reorder_buffer_3d_uint8")(rp).set_param(Param{"dim0", "1"}, Param{"dim1", "2"}, Param{"dim2", "0"});
84+
85+
/* image processing on the iamge obtained from the right sensor */
86+
n = b.add("image_processing_normalize_raw_image")(rp).set_param(Param{"bit_width", "12"}, Param{"bit_shift", "0"});
87+
n = b.add("image_processing_bayer_white_balance")(r_gain1_p, g_gain1_p, b_gain1_p, n["output"]).set_param(Param{"bayer_pattern", "GBRG"});
88+
n = b.add("image_processing_bayer_demosaic_simple")(n["output"]).set_param(
89+
Param{"bayer_pattern", "GBRG"},
90+
Param{"width", std::to_string(width)},
91+
Param{"height", std::to_string(height)}
92+
);
93+
n = b.add("image_processing_resize_bilinear_3d")(n["output"]).set_param(
94+
Param{"width", std::to_string(width)},
95+
Param{"height", std::to_string(height)},
96+
Param{"scale", std::to_string(2.0f)}
97+
);
98+
n = b.add("core_denormalize_3d_uint8")(n["output"]);
99+
n = b.add("image_processing_crop_image_3d_uint8")(n["output"]).set_param(
100+
Param{"input_width", std::to_string(width)},
101+
Param{"input_height", std::to_string(height)},
102+
Param{"output_width", std::to_string(width)},
103+
Param{"output_height", std::to_string(height)}
104+
); /*optional*/
63105
rp = n["output"];
64106

65107
// display images
@@ -81,6 +123,15 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path,
81123
pm.set(wp, width);
82124
pm.set(hp, height);
83125

126+
pm.set(r_gain0_p, header_info.r_gain0_);
127+
pm.set(g_gain0_p, header_info.g_gain0_);
128+
pm.set(b_gain0_p, header_info.b_gain0_);
129+
130+
pm.set(r_gain1_p, header_info.r_gain1_);
131+
pm.set(g_gain1_p, header_info.g_gain1_);
132+
pm.set(b_gain1_p, header_info.b_gain1_);
133+
134+
84135
/* output */
85136
Halide::Buffer<int> out0 = Halide::Buffer<int>::make_scalar();
86137
Halide::Buffer<int> out1 = Halide::Buffer<int>::make_scalar();
@@ -206,7 +257,7 @@ int main() {
206257

207258
rawHeader header_info = {
208259
0, width, height,
209-
0.5f, 1.0f, 1.5f, 1.2f, 2.2f, 0.2f,
260+
0.5f, 1.0f, 1.5f, 2.2f, 1.2f, 0.2f,
210261
0, 0, 0, 0, width, height, width, height, fps};
211262

212263
for (int i = 0; i < 50; ++i){

include/ion-bb-image-io/bb.h

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ class U3VCamera : public ion::BuildingBlock<U3VCamera> {
553553
GeneratorParam<std::string> pixel_format_ptr{"pixel_format_ptr", "RGB8"};
554554
GeneratorParam<std::string> gain_key_ptr{"gain_key", "Gain"};
555555
GeneratorParam<std::string> exposure_key_ptr{"exposure_key", "Exposure"};
556-
556+
557557
GeneratorInput<int32_t> gain0{ "gain0" };
558558
GeneratorInput<int32_t> gain1{ "gain1" };
559559
GeneratorInput<int32_t> exposure0{ "exposure0" };
@@ -607,65 +607,6 @@ class U3VCamera : public ion::BuildingBlock<U3VCamera> {
607607

608608
};
609609

610-
class Bayer2BGR : public ion::BuildingBlock<Bayer2BGR> {
611-
public:
612-
Input<Halide::Func> input{ "input", UInt(16), 2 };
613-
Input<int32_t> width{ "width" };
614-
Input<int32_t> height{ "height" };
615-
Output<Halide::Func> output{ "output", UInt(8), 3 };
616-
617-
void generate() {
618-
using namespace Halide;
619-
620-
Var x, y, c;
621-
622-
Func in = BoundaryConditions::repeat_edge(input, { {0, width}, {0, height} });
623-
624-
//
625-
// Assuming bayer pattern
626-
//
627-
// +---+---+---+---+
628-
// | G | B | G | B |...
629-
// +---+---+---+---+
630-
// | R | G | R | G |...
631-
// +---+---+---+---+
632-
// | G | B | G | B |...
633-
// +---+---+---+---+
634-
// .....................
635-
636-
Expr is_gb = (x % 2 == 0) && (y % 2 == 0);
637-
Expr is_b = (x % 2 == 1) && (y % 2 == 0);
638-
Expr is_r = (x % 2 == 0) && (y % 2 == 1);
639-
Expr is_gr = (x % 2 == 1) && (y % 2 == 1);
640-
641-
//
642-
// Neighbor pixel location
643-
//
644-
// p00 p10 p20
645-
// p01 p11 p21
646-
// p02 p12 p22
647-
648-
Expr p00 = in(x - 1, y - 1), p10 = in(x, y - 1), p20 = in(x + 1, y - 1);
649-
Expr p01 = in(x - 1, y), p11 = in(x, y), p21 = in(x + 1, y);
650-
Expr p02 = in(x - 1, y + 1), p12 = in(x, y + 1), p22 = in(x + 1, y + 1);
651-
652-
Expr self = p11;
653-
Expr hori = (p01 + p21) / 2;
654-
Expr vert = (p10 + p12) / 2;
655-
Expr latt = (p10 + p01 + p21 + p12) / 4;
656-
Expr diag = (p00 + p02 + p20 + p22) / 4;
657-
658-
// Assumes RAW has 12 bit resolutions
659-
Expr r = cast<uint8_t>(select(is_r, self, is_gr, hori, is_gb, vert, diag) >> 4);
660-
Expr g = cast<uint8_t>(select(is_r, latt, is_gr, diag, is_gb, diag, latt) >> 4);
661-
Expr b = cast<uint8_t>(select(is_r, diag, is_gr, vert, is_gb, hori, self) >> 4);
662-
663-
output(c, x, y) = select(c == 0, b, c == 1, g, r);
664-
}
665-
666-
private:
667-
Halide::Var c, x, y;
668-
};
669610

670611
class BinarySaver : public ion::BuildingBlock<BinarySaver> {
671612
public:
@@ -791,7 +732,6 @@ ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::GrayscaleDataLoader, image_io_gra
791732
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::ImageSaver, image_io_image_saver);
792733
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera, u3v_camera);
793734

794-
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::Bayer2BGR, image_io_bayer2bgr);
795735
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::BinarySaver, image_io_binarysaver);
796736
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::BinaryLoader, image_io_binaryloader);
797737

include/ion-bb-image-io/rt_display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@ extern "C" ION_EXPORT int ion_bb_image_io_gui_display(halide_buffer_t *in, int w
132132

133133
return 0;
134134
}
135+
ION_REGISTER_EXTERN(ion_bb_image_io_gui_display);
135136

136137
#endif

include/ion-bb-image-io/rt_u3v.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ class U3V{
131131
auto d = devices_[i];
132132
arv_device_execute_command(d.device_, "AcquisitionStop", nullptr);
133133

134-
for (auto b : buffers_[i]) {
135-
g_object_unref(reinterpret_cast<gpointer>(b));
136-
}
137-
134+
/*
135+
Note:
136+
unref stream also unref the buffers pushed to stream
137+
all buffers are in stream so do not undef buffres separately
138+
*/
138139
g_object_unref(reinterpret_cast<gpointer>(d.stream_));
139140
g_object_unref(reinterpret_cast<gpointer>(d.device_));
140141
}

0 commit comments

Comments
 (0)