@@ -78,6 +78,8 @@ static void resetControls( sl_oc::video::VideoCapture &cap );
78
78
// ----> Global variables
79
79
cv::String win_name = " Stream RGB" ; // Name of the stream window
80
80
bool selectInProgress = false ; // Indicates that an AECAGC ROI is being drawn
81
+ bool selectLeft = false ;
82
+ bool selectRight = false ;
81
83
cv::Rect aecagc_roi_left = {0 ,0 ,0 ,0 }; // The current agcaec ROI rectangle
82
84
cv::Rect aecagc_roi_right = {0 ,0 ,0 ,0 }; // The current agcaec ROI rectangle
83
85
cv::Point origin_roi = {0 ,0 }; // Click point for AECAGC ROI
@@ -101,7 +103,8 @@ uint8_t gamma_val;
101
103
bool autoAECAGC=false ;
102
104
bool autoWB=false ;
103
105
104
- bool applyAECAGCrect=false ;
106
+ bool applyAECAGCrectLeft=false ;
107
+ bool applyAECAGCrectRight=false ;
105
108
// <---- Global variables
106
109
107
110
// The main function
@@ -153,15 +156,23 @@ int main(int argc, char *argv[])
153
156
img_h = frame.height ;
154
157
155
158
// 3a) Apply AEC AGC ROI if necessary
156
- if (applyAECAGCrect )
159
+ if (applyAECAGCrectLeft )
157
160
{
158
- applyAECAGCrect = false ;
161
+ applyAECAGCrectLeft = false ;
159
162
cap.setROIforAECAGC ( sl_oc::video::CAM_SENS_POS::LEFT,
160
163
aecagc_roi_left.x , aecagc_roi_left.y ,
161
164
aecagc_roi_left.width , aecagc_roi_left.height );
165
+ selectLeft=false ;
166
+ selectRight=false ;
167
+ }
168
+ if (applyAECAGCrectRight)
169
+ {
170
+ applyAECAGCrectRight = false ;
162
171
cap.setROIforAECAGC ( sl_oc::video::CAM_SENS_POS::RIGHT,
163
- aecagc_roi_right.x , aecagc_roi_left.y ,
164
- aecagc_roi_left.width , aecagc_roi_left.height );
172
+ aecagc_roi_right.x , aecagc_roi_right.y ,
173
+ aecagc_roi_right.width , aecagc_roi_right.height );
174
+ selectLeft=false ;
175
+ selectRight=false ;
165
176
}
166
177
167
178
// ----> If the frame is valid we can display it
@@ -373,7 +384,16 @@ void handleMouse(int event, int x, int y, int, void*)
373
384
374
385
if (autoAECAGC && (activeControl==Gain || activeControl==Exposure))
375
386
{
376
- applyAECAGCrect = true ;
387
+ if (selectLeft)
388
+ {
389
+ selectLeft=false ;
390
+ applyAECAGCrectLeft = true ;
391
+ }
392
+ if (selectRight)
393
+ {
394
+ selectRight=false ;
395
+ applyAECAGCrectRight = true ;
396
+ }
377
397
}
378
398
break ;
379
399
}
@@ -384,7 +404,8 @@ void handleMouse(int event, int x, int y, int, void*)
384
404
selectInProgress = false ;
385
405
aecagc_roi_left = cv::Rect (0 ,0 ,img_w/2 ,img_h);
386
406
aecagc_roi_right = cv::Rect (0 ,0 ,img_w/2 ,img_h);
387
- applyAECAGCrect = true ;
407
+ applyAECAGCrectLeft = true ;
408
+ applyAECAGCrectRight = true ;
388
409
break ;
389
410
}
390
411
}
@@ -403,6 +424,7 @@ void handleMouse(int event, int x, int y, int, void*)
403
424
{
404
425
x = MAX (x,0 );
405
426
x = MIN (x,img_w/2 -1 );
427
+ selectLeft = true ;
406
428
407
429
aecagc_roi_left.x = MIN (x, or_x);
408
430
aecagc_roi_left.y = MIN (y, or_y);
@@ -415,6 +437,7 @@ void handleMouse(int event, int x, int y, int, void*)
415
437
x -= img_w/2 ;
416
438
x = MAX (x,0 );
417
439
x = MIN (x,img_w/2 -1 );
440
+ selectRight = true ;
418
441
419
442
aecagc_roi_right.x = MIN (x, or_x);
420
443
aecagc_roi_right.y = MIN (y, or_y);
0 commit comments