| 93 | } |
| 94 | |
| 95 | bool RecordController::screencap(cv::Mat& image) |
| 96 | { |
| 97 | auto start = std::chrono::steady_clock::now(); |
| 98 | bool success = inner_->screencap(image); |
| 99 | auto end = std::chrono::steady_clock::now(); |
| 100 | |
| 101 | auto timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(start - recording_start_).count(); |
| 102 | auto cost = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); |
| 103 | |
| 104 | RecordScreencap param; |
| 105 | |
| 106 | if (success && !image.empty()) { |
| 107 | std::unique_lock lock(recording_mutex_); |
| 108 | auto filename = std::format("screencap_{}.png", screencap_count_++); |
| 109 | param.path = screenshot_rel_prefix_ + "/" + filename; |
| 110 | lock.unlock(); |
| 111 | |
| 112 | MAA_NS::imwrite(screenshot_dir_ / filename, image); |
| 113 | } |
| 114 | |
| 115 | write_record(make_record_json(make_line(RecordType::screencap, success, timestamp, static_cast<int>(cost)), param)); |
| 116 | return success; |
| 117 | } |
| 118 | |
| 119 | bool RecordController::click(int x, int y) |
| 120 | { |