forked from dsutanto/bytetrack-counter-cpp
Reset delete live stream jpg as well
This commit is contained in:
1 parent
428f2a1140
commit
d44cb58416
2 files changed
+227
-6
No files matched your search
+226
-6
@@ -17,19 +17,19 @@
|
||||
"deletions": 0,
|
||||
"files": 0
|
||||
},
|
||||
"cost": 0.21404607100000003,
|
||||
"cost": 0.21538775600000004,
|
||||
"tokens": {
|
||||
"input": 229295,
|
||||
"output": 36279,
|
||||
"reasoning": 29904,
|
||||
"input": 229544,
|
||||
"output": 36551,
|
||||
"reasoning": 29935,
|
||||
"cache": {
|
||||
"read": 15647872,
|
||||
"read": 15915392,
|
||||
"write": 0
|
||||
}
|
||||
},
|
||||
"time": {
|
||||
"created": 1783419130384,
|
||||
"updated": 1785316263302
|
||||
"updated": 1785316898896
|
||||
}
|
||||
},
|
||||
"messages": [
|
||||
@@ -21722,6 +21722,226 @@
|
||||
"messageID": "msg_fad2435550018wohdUwDYyc0GF"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": {
|
||||
"role": "user",
|
||||
"time": {
|
||||
"created": 1785316887324
|
||||
},
|
||||
"agent": "build",
|
||||
"model": {
|
||||
"providerID": "deepseek",
|
||||
"modelID": "deepseek-v4-pro"
|
||||
},
|
||||
"summary": {
|
||||
"diffs": [
|
||||
{
|
||||
"file": "src/main.cpp",
|
||||
"patch": "Index: src/main.cpp\n===================================================================\n--- src/main.cpp\t\n+++ src/main.cpp\t\n@@ -1,582 +1,583 @@\n #include \"config.hpp\"\n #include \"bytetrack.hpp\"\n #include \"batch_store.hpp\"\n #include \"csv_logger.hpp\"\n #include \"rknn_yolo.hpp\"\n #include \"drawing.hpp\"\n #include \"nms.hpp\"\n #include \"version.hpp\"\n #include \"video_writer.hpp\"\n \n #include <opencv2/opencv.hpp>\n #include <Eigen/Dense>\n #include <csignal>\n #include <iostream>\n #include <chrono>\n #include <thread>\n #include <unordered_map>\n #include <unordered_set>\n #include <deque>\n #include <ctime>\n #include <filesystem>\n \n static std::atomic<bool> shutdown_requested{false};\n \n static void signal_handler(int) {\n shutdown_requested = true;\n std::cout << \"\\nShutdown requested — finishing current frame...\" << std::endl;\n }\n \n static std::string now_str() {\n auto now = std::chrono::system_clock::now();\n auto t = std::chrono::system_clock::to_time_t(now);\n std::ostringstream ss;\n ss << std::put_time(std::localtime(&t), \"%Y-%m-%d %H:%M:%S\");\n return ss.str();\n }\n \n static cv::VideoCapture open_capture(const std::string& source) {\n bool is_live = source.substr(0, 7) == \"rtsp://\" || source.substr(0, 7) == \"http://\";\n if (is_live) {\n setenv(\"OPENCV_FFMPEG_CAPTURE_OPTIONS\", g_config.rtsp_ffmpeg_options.c_str(), 1);\n }\n cv::VideoCapture cap(source, cv::CAP_FFMPEG);\n cap.set(cv::CAP_PROP_BUFFERSIZE, 1);\n return cap;\n }\n \n static void warmup_stream(cv::VideoCapture& cap, int n) {\n std::cout << \"Warming up stream...\" << std::endl;\n cv::Mat frame;\n for (int i = 0; i < n; ++i) cap.read(frame);\n std::cout << \"Stream ready!\" << std::endl;\n }\n \n static bool connect_stream(cv::VideoCapture& cap, int& w, int& h, double& fps) {\n bool is_live = g_config.source.substr(0, 7) == \"rtsp://\" ||\n g_config.source.substr(0, 7) == \"http://\";\n int attempts = 0;\n while (!shutdown_requested) {\n cap = open_capture(g_config.source);\n if (cap.isOpened()) break;\n attempts++;\n if (g_config.max_reconnect_attempts > 0 && attempts >= g_config.max_reconnect_attempts) {\n std::cerr << \"Cannot open source after \" << attempts\n << \" attempts: \" << g_config.source << std::endl;\n return false;\n }\n std::cout << \"Cannot open source, retry in \" << g_config.reconnect_delay_sec\n << \"s...\" << std::endl;\n std::this_thread::sleep_for(std::chrono::seconds(g_config.reconnect_delay_sec));\n }\n if (shutdown_requested) return false;\n \n if (is_live && g_config.warmup_frames > 0)\n warmup_stream(cap, g_config.warmup_frames);\n \n w = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_WIDTH));\n h = static_cast<int>(cap.get(cv::CAP_PROP_FRAME_HEIGHT));\n fps = cap.get(cv::CAP_PROP_FPS);\n if (fps <= 1) fps = g_config.output_fps;\n return true;\n }\n \n struct TrackedInfo {\n float cx;\n std::chrono::steady_clock::time_point ts;\n };\n \n static void prune_stale_tracks(std::unordered_map<int, TrackedInfo>& tracked, double prune_sec) {\n auto now = std::chrono::steady_clock::now();\n std::vector<int> stale;\n for (auto& [tid, info] : tracked) {\n auto age = std::chrono::duration_cast<std::chrono::seconds>(now - info.ts).count();\n if (age > prune_sec) stale.push_back(tid);\n }\n for (int tid : stale) tracked.erase(tid);\n }\n \n int main(int argc, char* argv[]) {\n signal(SIGINT, signal_handler);\n signal(SIGTERM, signal_handler);\n \n if (argc < 2) {\n std::cout << \"ByteTrack Counter (C++)\" << std::endl;\n std::cout << \"Version: \" << version::GIT_COMMIT\n << \" | branch: \" << version::GIT_BRANCH\n << \" | built: \" << version::BUILD_DATE << \" \" << version::BUILD_TIME\n << \" | rknn: \" << (version::BUILD_RKNN ? \"ON\" : \"OFF\");\n if (!version::GIT_TAG.empty())\n std::cout << \" | tag: \" << version::GIT_TAG;\n std::cout << std::endl;\n std::cout << \"Usage: bytetrack-counter <config.env>\" << std::endl;\n std::cout << \" config.env path to environment configuration file (required)\" << std::endl;\n return 1;\n }\n \n g_config.load_from_env(argv[1]);\n \n std::cout << \"Starting ByteTrack Counter (C++)\" << std::endl;\n std::cout << \"Version: \" << version::GIT_COMMIT\n << \" | branch: \" << version::GIT_BRANCH\n << \" | built: \" << version::BUILD_DATE << \" \" << version::BUILD_TIME\n << \" | rknn: \" << (version::BUILD_RKNN ? \"ON\" : \"OFF\");\n if (!version::GIT_TAG.empty())\n std::cout << \" | tag: \" << version::GIT_TAG;\Line truncated
|
||||
"additions": 1,
|
||||
"deletions": 0,
|
||||
"status": "modified"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": "msg_fad2dcb1c001pZ0fDpTdXPLYJX",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3"
|
||||
},
|
||||
"parts": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "when reset detected also delete LIVE STREAM jpg frame",
|
||||
"id": "prt_fad2dcb270013RKlE5Xbn89VR8",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2dcb1c001pZ0fDpTdXPLYJX"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": {
|
||||
"parentID": "msg_fad2dcb1c001pZ0fDpTdXPLYJX",
|
||||
"role": "assistant",
|
||||
"mode": "build",
|
||||
"agent": "build",
|
||||
"path": {
|
||||
"cwd": "/opt/bytetrack-counter-cpp",
|
||||
"root": "/opt/bytetrack-counter-cpp"
|
||||
},
|
||||
"cost": 0.000771081,
|
||||
"tokens": {
|
||||
"total": 134015,
|
||||
"input": 107,
|
||||
"output": 245,
|
||||
"reasoning": 31,
|
||||
"cache": {
|
||||
"write": 0,
|
||||
"read": 133632
|
||||
}
|
||||
},
|
||||
"modelID": "deepseek-v4-pro",
|
||||
"providerID": "deepseek",
|
||||
"time": {
|
||||
"created": 1785316887429,
|
||||
"completed": 1785316895612
|
||||
},
|
||||
"finish": "tool-calls",
|
||||
"id": "msg_fad2dcb85001X90c0q6YWT7252",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3"
|
||||
},
|
||||
"parts": [
|
||||
{
|
||||
"snapshot": "4606fb94c80d7184f2f3037d6623e6ff31c17ba8",
|
||||
"type": "step-start",
|
||||
"id": "prt_fad2ddc86001LrOha94a5rXMee",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2dcb85001X90c0q6YWT7252"
|
||||
},
|
||||
{
|
||||
"type": "reasoning",
|
||||
"text": "The user wants the `.reset` file detection to also delete the live stream JPEG frame (from `LIVE_STREAM_FRAME_PATH` config).",
|
||||
"time": {
|
||||
"start": 1785316892475,
|
||||
"end": 1785316893365
|
||||
},
|
||||
"id": "prt_fad2ddf3b001yCtS1XeRL5DQPQ",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2dcb85001X90c0q6YWT7252"
|
||||
},
|
||||
{
|
||||
"type": "tool",
|
||||
"tool": "edit",
|
||||
"callID": "call_00_qMffgVDwCzE9vJywHlrc9262",
|
||||
"state": {
|
||||
"status": "completed",
|
||||
"input": {
|
||||
"filePath": "/opt/bytetrack-counter-cpp/src/main.cpp",
|
||||
"newString": " if (std::filesystem::exists(reset_file)) {\n std::cout << \"[RESET] .reset detected — clearing state\" << std::endl;\n std::error_code ec;\n std::filesystem::remove(g_config.state_file, ec);\n std::filesystem::remove(g_config.live_stream_frame_path, ec);\n std::filesystem::remove(reset_file, ec);\n }",
|
||||
"oldString": " if (std::filesystem::exists(reset_file)) {\n std::cout << \"[RESET] .reset detected — clearing state\" << std::endl;\n std::error_code ec;\n std::filesystem::remove(g_config.state_file, ec);\n std::filesystem::remove(reset_file, ec);\n }"
|
||||
},
|
||||
"output": "Edit applied successfully.",
|
||||
"metadata": {
|
||||
"diagnostics": {},
|
||||
"diff": "Index: /opt/bytetrack-counter-cpp/src/main.cpp\n===================================================================\n--- /opt/bytetrack-counter-cpp/src/main.cpp\n+++ /opt/bytetrack-counter-cpp/src/main.cpp\n@@ -146,8 +146,9 @@\n if (std::filesystem::exists(reset_file)) {\n std::cout << \"[RESET] .reset detected — clearing state\" << std::endl;\n std::error_code ec;\n std::filesystem::remove(g_config.state_file, ec);\n+ std::filesystem::remove(g_config.live_stream_frame_path, ec);\n std::filesystem::remove(reset_file, ec);\n }\n }\n \n",
|
||||
"filediff": {
|
||||
"file": "/opt/bytetrack-counter-cpp/src/main.cpp",
|
||||
"patch": "Index: /opt/bytetrack-counter-cpp/src/main.cpp\n===================================================================\n--- /opt/bytetrack-counter-cpp/src/main.cpp\n+++ /opt/bytetrack-counter-cpp/src/main.cpp\n@@ -146,8 +146,9 @@\n if (std::filesystem::exists(reset_file)) {\n std::cout << \"[RESET] .reset detected — clearing state\" << std::endl;\n std::error_code ec;\n std::filesystem::remove(g_config.state_file, ec);\n+ std::filesystem::remove(g_config.live_stream_frame_path, ec);\n std::filesystem::remove(reset_file, ec);\n }\n }\n \n",
|
||||
"additions": 1,
|
||||
"deletions": 0
|
||||
},
|
||||
"truncated": false
|
||||
},
|
||||
"title": "src/main.cpp",
|
||||
"time": {
|
||||
"start": 1785316895193,
|
||||
"end": 1785316895204
|
||||
}
|
||||
},
|
||||
"id": "prt_fad2de2bc001oXtGSVn0eNp0Mr",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2dcb85001X90c0q6YWT7252"
|
||||
},
|
||||
{
|
||||
"reason": "tool-calls",
|
||||
"snapshot": "7a603081d1ecf645fefa416e0364e0f3face7d8d",
|
||||
"type": "step-finish",
|
||||
"tokens": {
|
||||
"total": 134015,
|
||||
"input": 107,
|
||||
"output": 245,
|
||||
"reasoning": 31,
|
||||
"cache": {
|
||||
"write": 0,
|
||||
"read": 133632
|
||||
}
|
||||
},
|
||||
"cost": 0.000771081,
|
||||
"id": "prt_fad2dead4001gaGahwPPiMfD5g",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2dcb85001X90c0q6YWT7252"
|
||||
},
|
||||
{
|
||||
"type": "patch",
|
||||
"hash": "4606fb94c80d7184f2f3037d6623e6ff31c17ba8",
|
||||
"files": [
|
||||
"/opt/bytetrack-counter-cpp/src/main.cpp"
|
||||
],
|
||||
"id": "prt_fad2deb5c001FWOgzdx5vP1JJb",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2dcb85001X90c0q6YWT7252"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": {
|
||||
"parentID": "msg_fad2dcb1c001pZ0fDpTdXPLYJX",
|
||||
"role": "assistant",
|
||||
"mode": "build",
|
||||
"agent": "build",
|
||||
"path": {
|
||||
"cwd": "/opt/bytetrack-counter-cpp",
|
||||
"root": "/opt/bytetrack-counter-cpp"
|
||||
},
|
||||
"cost": 0.000570604,
|
||||
"tokens": {
|
||||
"total": 134057,
|
||||
"input": 142,
|
||||
"output": 27,
|
||||
"reasoning": 0,
|
||||
"cache": {
|
||||
"write": 0,
|
||||
"read": 133888
|
||||
}
|
||||
},
|
||||
"modelID": "deepseek-v4-pro",
|
||||
"providerID": "deepseek",
|
||||
"time": {
|
||||
"created": 1785316895654,
|
||||
"completed": 1785316898843
|
||||
},
|
||||
"finish": "stop",
|
||||
"id": "msg_fad2deba6001GGfVEXi3CANMeM",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3"
|
||||
},
|
||||
"parts": [
|
||||
{
|
||||
"snapshot": "7a603081d1ecf645fefa416e0364e0f3face7d8d",
|
||||
"type": "step-start",
|
||||
"id": "prt_fad2df2c5001RZt5Mqz1NypEm3",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2deba6001GGfVEXi3CANMeM"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Done. `.reset` now clears `STATE_FILE`, `LIVE_STREAM_FRAME_PATH`, then deletes itself.",
|
||||
"time": {
|
||||
"start": 1785316898131,
|
||||
"end": 1785316898578
|
||||
},
|
||||
"id": "prt_fad2df553001A23rMdhe6fERXF",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2deba6001GGfVEXi3CANMeM"
|
||||
},
|
||||
{
|
||||
"reason": "stop",
|
||||
"snapshot": "7a603081d1ecf645fefa416e0364e0f3face7d8d",
|
||||
"type": "step-finish",
|
||||
"tokens": {
|
||||
"total": 134057,
|
||||
"input": 142,
|
||||
"output": 27,
|
||||
"reasoning": 0,
|
||||
"cache": {
|
||||
"write": 0,
|
||||
"read": 133888
|
||||
}
|
||||
},
|
||||
"cost": 0.000570604,
|
||||
"id": "prt_fad2df79b001d41u61nK2WXcR2",
|
||||
"sessionID": "ses_0c3efadf0ffeP4HreoRuvKX5h3",
|
||||
"messageID": "msg_fad2deba6001GGfVEXi3CANMeM"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -147,6 +147,7 @@ int main(int argc, char* argv[]) {
|
||||
std::cout << "[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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user