diff options
author | Your Name <you@example.com> | 2021-08-17 08:56:06 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-08-17 08:56:06 -0400 |
commit | 8a6b5564c0fc37e6e556d04e17ddba86d4bd3dc1 (patch) | |
tree | 238d013eb3cfe2dc170a52dec3bfcd72a1e468ca /src/ui.cc | |
parent | 8c884838ced928d29a8436be8b2808766c5a1e53 (diff) | |
download | annotator-8a6b5564c0fc37e6e556d04e17ddba86d4bd3dc1.tar.gz annotator-8a6b5564c0fc37e6e556d04e17ddba86d4bd3dc1.tar.bz2 annotator-8a6b5564c0fc37e6e556d04e17ddba86d4bd3dc1.zip |
Started work on bounding boxes
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(); |