Skip to content

Commit d689961

Browse files
author
Walter Lucetti
committed
Fix ROI selection for right image
1 parent 41dae63 commit d689961

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

examples/zed_oc_control_example.cpp

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static void resetControls( sl_oc::video::VideoCapture &cap );
7878
// ----> Global variables
7979
cv::String win_name = "Stream RGB"; // Name of the stream window
8080
bool selectInProgress = false; // Indicates that an AECAGC ROI is being drawn
81+
bool selectLeft = false;
82+
bool selectRight = false;
8183
cv::Rect aecagc_roi_left = {0,0,0,0}; // The current agcaec ROI rectangle
8284
cv::Rect aecagc_roi_right = {0,0,0,0}; // The current agcaec ROI rectangle
8385
cv::Point origin_roi = {0,0}; // Click point for AECAGC ROI
@@ -101,7 +103,8 @@ uint8_t gamma_val;
101103
bool autoAECAGC=false;
102104
bool autoWB=false;
103105

104-
bool applyAECAGCrect=false;
106+
bool applyAECAGCrectLeft=false;
107+
bool applyAECAGCrectRight=false;
105108
// <---- Global variables
106109

107110
// The main function
@@ -153,15 +156,23 @@ int main(int argc, char *argv[])
153156
img_h = frame.height;
154157

155158
// 3a) Apply AEC AGC ROI if necessary
156-
if(applyAECAGCrect)
159+
if(applyAECAGCrectLeft)
157160
{
158-
applyAECAGCrect = false;
161+
applyAECAGCrectLeft = false;
159162
cap.setROIforAECAGC( sl_oc::video::CAM_SENS_POS::LEFT,
160163
aecagc_roi_left.x, aecagc_roi_left.y,
161164
aecagc_roi_left.width, aecagc_roi_left.height);
165+
selectLeft=false;
166+
selectRight=false;
167+
}
168+
if(applyAECAGCrectRight)
169+
{
170+
applyAECAGCrectRight = false;
162171
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;
165176
}
166177

167178
// ----> If the frame is valid we can display it
@@ -373,7 +384,16 @@ void handleMouse(int event, int x, int y, int, void*)
373384

374385
if(autoAECAGC && (activeControl==Gain || activeControl==Exposure))
375386
{
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+
}
377397
}
378398
break;
379399
}
@@ -384,7 +404,8 @@ void handleMouse(int event, int x, int y, int, void*)
384404
selectInProgress = false;
385405
aecagc_roi_left = cv::Rect(0,0,img_w/2,img_h);
386406
aecagc_roi_right = cv::Rect(0,0,img_w/2,img_h);
387-
applyAECAGCrect = true;
407+
applyAECAGCrectLeft = true;
408+
applyAECAGCrectRight = true;
388409
break;
389410
}
390411
}
@@ -403,6 +424,7 @@ void handleMouse(int event, int x, int y, int, void*)
403424
{
404425
x = MAX(x,0);
405426
x = MIN(x,img_w/2-1);
427+
selectLeft = true;
406428

407429
aecagc_roi_left.x = MIN(x, or_x);
408430
aecagc_roi_left.y = MIN(y, or_y);
@@ -415,6 +437,7 @@ void handleMouse(int event, int x, int y, int, void*)
415437
x -= img_w/2;
416438
x = MAX(x,0);
417439
x = MIN(x,img_w/2-1);
440+
selectRight = true;
418441

419442
aecagc_roi_right.x = MIN(x, or_x);
420443
aecagc_roi_right.y = MIN(y, or_y);

src/videocapture.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ void VideoCapture::grabThreadFunc()
838838
{
839839
static int frame_count =0;
840840

841+
841842
if((++frame_count)==mLogFrameSkip)
842843
frame_count = 0;
843844

0 commit comments

Comments
 (0)