Skip to content

Commit a93492d

Browse files
authoredMar 17, 2025
add autexp region params (#695)
1 parent f5b4496 commit a93492d

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
 

‎depthai_ros_driver/cfg/parameters.cfg

+15
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ camera.add("left_r_set_chroma_denoise", bool_t, 0, "Enable chroma denoise", Fals
2929
camera.add("left_r_chroma_denoise", int_t, 0, "Chroma denoise", 0, 0, 4)
3030
camera.add("left_r_set_luma_denoise", bool_t, 0, "Enable luma denoise", False)
3131
camera.add("left_r_luma_denoise", int_t, 0, "Luma denoise", 0, 0, 4)
32+
camera.add("left_r_set_auto_exp_region", bool_t, 0, "Enable auto exposure region", False)
33+
camera.add("left_r_auto_exp_region_start_x", int_t, 0, "Auto exposure region start x", 0, 0)
34+
camera.add("left_r_auto_exp_region_start_y", int_t, 0, "Auto exposure region start y", 0, 0)
35+
camera.add("left_r_auto_exp_region_width", int_t, 0, "Auto exposure region width", 0, 0)
36+
camera.add("left_r_auto_exp_region_height", int_t, 0, "Auto exposure region height", 0, 0)
3237

3338
camera.add("right_r_keep_preview_aspect_ratio", bool_t, 0, "Keep preview aspect ratio", True)
3439
camera.add("right_r_exposure", int_t, 0, "Sensor exposure", 1000, 1, 33000)
@@ -46,6 +51,11 @@ camera.add("right_r_set_chroma_denoise", bool_t, 0, "Enable chroma denoise", Fal
4651
camera.add("right_r_chroma_denoise", int_t, 0, "Chroma denoise", 0, 0, 4)
4752
camera.add("right_r_set_luma_denoise", bool_t, 0, "Enable luma denoise", False)
4853
camera.add("right_r_luma_denoise", int_t, 0, "Luma denoise", 0, 0, 4)
54+
camera.add("right_r_set_auto_exp_region", bool_t, 0, "Enable auto exposure region", False)
55+
camera.add("right_r_auto_exp_region_start_x", int_t, 0, "Auto exposure region start x", 0, 0)
56+
camera.add("right_r_auto_exp_region_start_y", int_t, 0, "Auto exposure region start y", 0, 0)
57+
camera.add("right_r_auto_exp_region_width", int_t, 0, "Auto exposure region width", 0, 0)
58+
camera.add("right_r_auto_exp_region_height", int_t, 0, "Auto exposure region height", 0, 0)
4959

5060
camera.add("rgb_r_keep_preview_aspect_ratio", bool_t, 0, "Keep preview aspect ratio", True)
5161
camera.add("rgb_r_exposure", int_t, 0, "Sensor exposure", 1000, 1, 33000)
@@ -63,5 +73,10 @@ camera.add("rgb_r_set_chroma_denoise", bool_t, 0, "Enable chroma denoise", False
6373
camera.add("rgb_r_chroma_denoise", int_t, 0, "Chroma denoise", 0, 0, 4)
6474
camera.add("rgb_r_set_luma_denoise", bool_t, 0, "Enable luma denoise", False)
6575
camera.add("rgb_r_luma_denoise", int_t, 0, "Luma denoise", 0, 0, 4)
76+
camera.add("rgb_r_set_auto_exp_region", bool_t, 0, "Enable auto exposure region", False)
77+
camera.add("rgb_r_auto_exp_region_start_x", int_t, 0, "Auto exposure region start x", 0, 0)
78+
camera.add("rgb_r_auto_exp_region_start_y", int_t, 0, "Auto exposure region start y", 0, 0)
79+
camera.add("rgb_r_auto_exp_region_width", int_t, 0, "Auto exposure region width", 0, 0)
80+
camera.add("rgb_r_auto_exp_region_height", int_t, 0, "Auto exposure region height", 0, 0)
6681

6782
exit(gen.generate(PACKAGE, "depthai_ros_driver", "parameters"))

‎depthai_ros_driver/src/param_handlers/sensor_param_handler.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ void SensorParamHandler::declareParams(std::shared_ptr<dai::node::MonoCamera> mo
103103
if(declareAndLogParam("r_set_luma_denoise", false)) {
104104
monoCam->initialControl.setLumaDenoise(lumaDenoise);
105105
}
106+
bool setAutoExpRegion = declareAndLogParam<bool>("r_set_auto_exp_region", false);
107+
int autoExpStartX = declareAndLogParam<int>("r_auto_exp_region_start_x", 0);
108+
int autoExpStartY = declareAndLogParam<int>("r_auto_exp_region_start_y", 0);
109+
int autoExpWidth = declareAndLogParam<int>("r_auto_exp_region_width", 0);
110+
int autoExpHeight = declareAndLogParam<int>("r_auto_exp_region_height", 0);
111+
if(setAutoExpRegion) {
112+
monoCam->initialControl.setAutoExposureRegion(autoExpStartX, autoExpStartY, autoExpWidth, autoExpHeight);
113+
}
106114
}
107115

108116
void SensorParamHandler::declareParams(std::shared_ptr<dai::node::ColorCamera> colorCam, dai_nodes::sensor_helpers::ImageSensor sensor, bool publish) {
@@ -211,6 +219,14 @@ void SensorParamHandler::declareParams(std::shared_ptr<dai::node::ColorCamera> c
211219
if(declareAndLogParam("r_set_luma_denoise", false)) {
212220
colorCam->initialControl.setLumaDenoise(lumaDenoise);
213221
}
222+
bool setAutoExpRegion = declareAndLogParam<bool>("r_set_auto_exp_region", false);
223+
int autoExpStartX = declareAndLogParam<int>("r_auto_exp_region_start_x", 0);
224+
int autoExpStartY = declareAndLogParam<int>("r_auto_exp_region_start_y", 0);
225+
int autoExpWidth = declareAndLogParam<int>("r_auto_exp_region_width", 0);
226+
int autoExpHeight = declareAndLogParam<int>("r_auto_exp_region_height", 0);
227+
if(setAutoExpRegion) {
228+
colorCam->initialControl.setAutoExposureRegion(autoExpStartX, autoExpStartY, autoExpWidth, autoExpHeight);
229+
}
214230
}
215231
dai::CameraControl SensorParamHandler::setRuntimeParams(parametersConfig& config) {
216232
dai::CameraControl ctrl;
@@ -244,6 +260,10 @@ dai::CameraControl SensorParamHandler::setRuntimeParams(parametersConfig& config
244260
if(config.rgb_r_set_luma_denoise) {
245261
ctrl.setLumaDenoise(config.rgb_r_luma_denoise);
246262
}
263+
if(config.rgb_r_set_auto_exp_region) {
264+
ctrl.setAutoExposureRegion(config.rgb_r_auto_exp_region_start_x, config.rgb_r_auto_exp_region_start_y, config.rgb_r_auto_exp_region_width,
265+
config.rgb_r_auto_exp_region_height);
266+
}
247267
} else if(getName() == "left") {
248268
if(config.left_r_set_man_exposure) {
249269
ctrl.setManualExposure(config.left_r_exposure, config.left_r_iso);
@@ -273,6 +293,10 @@ dai::CameraControl SensorParamHandler::setRuntimeParams(parametersConfig& config
273293
if(config.left_r_set_luma_denoise) {
274294
ctrl.setLumaDenoise(config.left_r_luma_denoise);
275295
}
296+
if(config.left_r_set_auto_exp_region) {
297+
ctrl.setAutoExposureRegion(config.left_r_auto_exp_region_start_x, config.left_r_auto_exp_region_start_y, config.left_r_auto_exp_region_width,
298+
config.left_r_auto_exp_region_height);
299+
}
276300
} else if(getName() == "right") {
277301
if(config.right_r_set_man_exposure) {
278302
ctrl.setManualExposure(config.right_r_exposure, config.right_r_iso);
@@ -302,6 +326,10 @@ dai::CameraControl SensorParamHandler::setRuntimeParams(parametersConfig& config
302326
if(config.right_r_set_luma_denoise) {
303327
ctrl.setLumaDenoise(config.right_r_luma_denoise);
304328
}
329+
if(config.right_r_set_auto_exp_region) {
330+
ctrl.setAutoExposureRegion(config.right_r_auto_exp_region_start_x, config.right_r_auto_exp_region_start_y, config.right_r_auto_exp_region_width,
331+
config.right_r_auto_exp_region_height);
332+
}
305333
}
306334

307335
return ctrl;

0 commit comments

Comments
 (0)