From e4ec24000b7ed45490eaa988c94546f480114933 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 17 Aug 2021 16:29:44 -0400 Subject: Finished rectangle annotation code --- src/ui.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/ui.cc') diff --git a/src/ui.cc b/src/ui.cc index 9b24815..3940955 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -36,20 +36,24 @@ namespace frontend { case 32: // Space pauses data->play = ! data->play; break; - case 65361: // Left seeks backward 1 frame + case 104: + case 65361: // Left seeks backward 1 frame (or h) data->pb->seekFrame(data->pb->getFrame() - 1); break; - case 65362: // Up seeks backward 1 second + case 100: + case 65362: // Up seeks backward 1 second (or d) if(data->pb->getTime() < 1) { data->pb->seekTime(data->pb->getTime() * -1); } else { data->pb->seekTime(data->pb->getTime() - 1); } break; - case 65363: // Right seeks forward 1 frame + case 116: + case 65363: // Right seeks forward 1 frame (or t) data->pb->seekFrame(data->pb->getFrame() + 1); break; - case 65364: // Down seeks forward 1 second + case 110: + case 65364: // Down seeks forward 1 second (or n) data->pb->seekTime(data->pb->getTime() + 1); break; case 117: // u undoes @@ -74,9 +78,9 @@ namespace frontend { } backend::label* getCurrentRectLabel(ui_impl *data) { - auto labs = data->llr->getEditableLabels(); + auto &labs = data->llr->getEditableLabels(); for(auto rit = labs.rbegin(); rit != labs.rend(); rit++) { - if(rit->location.nonzero()) { + if(rit->location.nonzero() && rit->time <= data->pb->getTime()) { return &(*rit); } } @@ -106,8 +110,8 @@ namespace frontend { data->llr->applyLabel(name, time); lab = &data->llr->getEditableLabels().back(); } - lab->location.x1 = x; - lab->location.y1 = y; + lab->location.x1 = lab->location.x2 = x; + lab->location.y1 = lab->location.y2 = y; } else if(event == cv::EVENT_LBUTTONUP) { // Mouse is no longer down mouseDown = false; @@ -115,7 +119,7 @@ namespace frontend { // If the mouse is down, update x2 and y2 of current window if(mouseDown) { auto lab = getCurrentRectLabel(data); // It will be valid! TODO: Will it? - std::cout << "Updating location from " << lab->location.x2 << ", " << lab->location.y2 << " to " << x << ", " << y << "\n"; + //std::cout << "Updating location from " << lab->location.x2 << ", " << lab->location.y2 << " to " << x << ", " << y << "\n"; lab->location.x2 = x; lab->location.y2 = y; } -- cgit v1.2.3