Reset delete live stream jpg as well (Reset buffer)

This commit is contained in:
proitlab committed 2026-07-29 16:44:18 +07:00
1 parent d44cb58416
commit 4ff0fdd0aa
3 files changed
+1732 -7

No files matched your search

+1713 -6
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
+19 -1
View File
@@ -244,12 +244,25 @@ int main(int argc, char* argv[]) {
} }
int reconnect_count = 0; int reconnect_count = 0;
bool blank_live_frame = false;
std::unordered_map<int, TrackedInfo> ayam_tracked; std::unordered_map<int, TrackedInfo> ayam_tracked;
std::unordered_map<int, TrackedInfo> talenan_tracked; std::unordered_map<int, TrackedInfo> talenan_tracked;
cv::Mat prev_gray; cv::Mat prev_gray;
while (!shutdown_requested) { while (!shutdown_requested) {
{
std::string reset_file = g_config.shm_dir + "/.reset";
if (std::filesystem::exists(reset_file)) {
std::cout << "[" << now_str() << "] [RESET] .reset detected — clearing state" << std::endl;
std::error_code ec;
std::filesystem::remove(g_config.state_file, ec);
std::filesystem::remove(g_config.live_stream_frame_path, ec);
std::filesystem::remove(reset_file, ec);
blank_live_frame = true;
}
}
cv::Mat frame; cv::Mat frame;
cap >> frame; cap >> frame;
if (frame.empty()) { if (frame.empty()) {
@@ -558,8 +571,13 @@ int main(int argc, char* argv[]) {
std::filesystem::path p(g_config.live_stream_frame_path); std::filesystem::path p(g_config.live_stream_frame_path);
if (p.has_parent_path()) if (p.has_parent_path())
std::filesystem::create_directories(p.parent_path()); std::filesystem::create_directories(p.parent_path());
cv::Mat out_frame = frame;
if (blank_live_frame) {
out_frame = cv::Mat::zeros(frame.size(), frame.type());
blank_live_frame = false;
}
std::vector<uint8_t> jpeg; std::vector<uint8_t> jpeg;
cv::imencode(".jpg", frame, jpeg, cv::imencode(".jpg", out_frame, jpeg,
{cv::IMWRITE_JPEG_QUALITY, g_config.live_stream_quality}); {cv::IMWRITE_JPEG_QUALITY, g_config.live_stream_quality});
std::ofstream f(g_config.live_stream_frame_path, std::ios::binary); std::ofstream f(g_config.live_stream_frame_path, std::ios::binary);
f.write(reinterpret_cast<const char*>(jpeg.data()), jpeg.size()); f.write(reinterpret_cast<const char*>(jpeg.data()), jpeg.size());