| 2205 | } |
| 2206 | |
| 2207 | bool handleKey(int c) { |
| 2208 | const std::string key2part = "0123456789qwertyuiopas"; |
| 2209 | VLOG(4) << "key: " << (char)c << " code: " << c; |
| 2210 | if (c>=65505) { |
| 2211 | global.uistate.is_shift_down = true; |
| 2212 | c = (char)c; |
| 2213 | c = tolower(c); |
| 2214 | VLOG(4) << "post key: " << (char)c << " code: " << c; |
| 2215 | } else { |
| 2216 | global.uistate.is_shift_down = false; |
| 2217 | } |
| 2218 | VLOG(4) << "shift: " << global.uistate.is_shift_down; |
| 2219 | if (c==27) { |
| 2220 | global.quit_threads = true; |
| 2221 | return false; |
| 2222 | } |
| 2223 | |
| 2224 | if (c=='g') { |
| 2225 | global.uistate.is_googly_eyes = !global.uistate.is_googly_eyes; |
| 2226 | } |
| 2227 | |
| 2228 | // Rudimentary seeking in video |
| 2229 | if (c=='l' || c=='k' || c==' ') { |
| 2230 | if (!_video.empty()) { |
| 2231 | int cur_frame = global.uistate.current_frame; |
| 2232 | int frame_delta = 30; |
| 2233 | if (global.uistate.is_shift_down) |
| 2234 | frame_delta = 2; |
| 2235 | if (c=='l') { |
| 2236 | VLOG(4) << "Jump " << frame_delta << " frames to " << cur_frame; |
| 2237 | global.uistate.current_frame+=frame_delta; |
| 2238 | global.uistate.seek_to_frame = 1; |
| 2239 | } else if (c=='k') { |
| 2240 | VLOG(4) << "Rewind " << frame_delta << " frames to " << cur_frame; |
| 2241 | global.uistate.current_frame-=frame_delta; |
| 2242 | global.uistate.seek_to_frame = 1; |
| 2243 | } |
| 2244 | } |
| 2245 | if (c==' ') { |
| 2246 | global.uistate.is_video_paused = !global.uistate.is_video_paused; |
| 2247 | } |
| 2248 | } |
| 2249 | if (c=='f') { |
| 2250 | if (!global.uistate.is_fullscreen) { |
| 2251 | cv::namedWindow("video", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); |
| 2252 | cv::resizeWindow("video", 1920, 1080); |
| 2253 | cv::setWindowProperty("video", CV_WND_PROP_FULLSCREEN, |
| 2254 | CV_WINDOW_FULLSCREEN); |
| 2255 | global.uistate.is_fullscreen = true; |
| 2256 | } else { |
| 2257 | cv::namedWindow("video", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO); |
| 2258 | cv::setWindowProperty("video", CV_WND_PROP_FULLSCREEN, CV_WINDOW_NORMAL); |
| 2259 | cv::resizeWindow("video", DISPLAY_RESOLUTION_WIDTH, |
| 2260 | DISPLAY_RESOLUTION_HEIGHT); |
| 2261 | global.uistate.is_fullscreen = false; |
| 2262 | } |
| 2263 | } |
| 2264 | int target = -1; |