Log for Batch closed

This commit is contained in:
proitlab committed 2026-07-07 15:59:18 +07:00
1 parent 60a02f429c
commit a5c146ec98
5 files changed
+43 -7

No files matched your search

+1 -1
View File
@@ -32,5 +32,5 @@
*.out
*.app
# Evn
# Env
.env*
Binary file not shown.
+3 -3
View File
@@ -4,11 +4,11 @@
namespace version {
const std::string GIT_COMMIT = "bed242d2";
const std::string GIT_COMMIT = "60a02f42";
const std::string GIT_BRANCH = "main";
const std::string GIT_TAG = "";
const std::string BUILD_DATE = "2026-07-06";
const std::string BUILD_TIME = "22:54:19";
const std::string BUILD_DATE = "2026-07-07";
const std::string BUILD_TIME = "15:57:21";
const int BUILD_YEAR = 2026;
const bool BUILD_RKNN = 1;
+18 -3
View File
@@ -97,6 +97,9 @@ RTSP_FFMPEG_OPTIONS = os.getenv(
IS_LIVE = SOURCE.lower().startswith(("rtsp://", "http://"))
MOTION_DETECTION_ENABLED = os.getenv("MOTION_DETECTION_ENABLED", "false").lower() == "true"
MOTION_THRESHOLD = float(os.getenv("MOTION_THRESHOLD", "5.0"))
CROSS_FLASH_FRAMES = 12
POPUP_LIFETIME = 20
LINE_PULSE_FRAMES = 12
@@ -1014,6 +1017,7 @@ def run():
session_start = time.time()
frame_idx = 0
inf_ms = 0.0
prev_gray = None
video_writer = None
crossing_times = deque()
@@ -1066,9 +1070,20 @@ def run():
mono = time.monotonic()
ayam_crossed_frame = batch_closed_frame = batch_started_frame = False
inf_start = time.time()
detections = model(frame)
inf_ms = inf_ms * 0.9 + (time.time() - inf_start) * 1000 * 0.1
skip_inference = False
if MOTION_DETECTION_ENABLED:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
if prev_gray is not None:
diff = cv2.absdiff(gray, prev_gray)
mean_diff = cv2.mean(diff)[0]
skip_inference = mean_diff < MOTION_THRESHOLD
prev_gray = gray
detections = []
if not skip_inference:
inf_start = time.time()
detections = model(frame)
inf_ms = inf_ms * 0.9 + (time.time() - inf_start) * 1000 * 0.1
if detections:
ayam_boxes_xyxy = []
+21
View File
@@ -273,6 +273,27 @@ std::pair<int, bool> BatchStore::record_ayam_crossing(int track_id) {
bool BatchStore::record_talenan_crossing(int track_id) {
if (ignore_batch_label_) return false;
std::lock_guard<std::mutex> lock(state_mutex_);
{
int count = current_state_.is_null() ? 0 : current_state_["count"].get<int>();
std::string start_time = current_state_.is_null() ? "" : current_state_["start_time"];
std::string end_time = now_iso();
auto duration_sec = 0LL;
if (!start_time.empty()) {
std::tm tm = {};
std::istringstream ss(start_time);
ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%S");
auto start_tp = std::chrono::system_clock::from_time_t(std::mktime(&tm));
auto end_tp = std::chrono::system_clock::now();
duration_sec = std::chrono::duration_cast<std::chrono::seconds>(end_tp - start_tp).count();
}
std::ostringstream msg;
msg << "Batch closed by talenan crossing"
<< " | count=" << count
<< " | duration=" << duration_sec << "s"
<< " | start=" << start_time
<< " | end=" << end_time;
logger_(msg.str());
}
ignore_batch_label_fn();
end_batch_locked("talenan");
batch_timer_running_ = false;