@@ -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){
0 commit comments