MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / screencap

Method screencap

source/MaaRecordControlUnit/RecordController.cpp:95–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95bool 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
119bool RecordController::click(int x, int y)
120{

Callers

nothing calls this directly

Calls 2

screencapMethod · 0.65
emptyMethod · 0.45

Tested by

no test coverage detected