diff options
Diffstat (limited to 'src/ui.cc')
-rw-r--r-- | src/ui.cc | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -73,6 +73,32 @@ namespace frontend { return false; } + void mouseCallback(int event, int x, int y, int flags, void* userdata) { + // userdata is actually a &shared_ptr<ui_impl> + shared_ptr<ui_impl> data = (shared_ptr<ui_impl>) *userdata; + static bool mouseDown = false; + // We're interested in left button down/up and movement when down + if(event == cv::EVENT_LBUTTONDOWN) { + // If the current frame doesn't have a rectangle label, then make one + mouseDown = true; + double time = data->pb->getTime() + auto labs = data->llr->getSurrounding(time); + backend::label current; + if(labs.first.time == time) { + current = labs.first; + } else if(labs.second.time == time) { + current = labs.second; + } else { + + } + } else if(event == cv::EVENT_LBUTTONUP) { + // Mouse is no longer down + mouseDown = false; + } else if(event == cv::EVENT_MOUSEMOVE) { + // If the mouse is down, update x2 and y2 of current window + } + } + void ui::begin() { std::cout << "Playing a video that's " << data->pb->getMaxFrame() << " frames (" << data->pb->getMaxTime() << " seconds) long." << std::endl; std::cout << "Annotations:" << std::endl; @@ -84,6 +110,8 @@ namespace frontend { struct winsize size; ioctl(STDOUT_FILENO, TIOCGWINSZ, &size); int cols = size.ws_col; + // Register mouse callback + cv::setMouseCallback("Video", mouseCallback, &data); while(true) { data->pb->display("Video"); data->pb->interFrameSleep(); |