mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-17 10:00:46 -04:00
guhb
This commit is contained in:
@@ -8,6 +8,7 @@ const roverManager = require('./roverManager');
|
|||||||
const { issueCommand } = require('./commandService');
|
const { issueCommand } = require('./commandService');
|
||||||
const { publishEvent } = require('./eventBus');
|
const { publishEvent } = require('./eventBus');
|
||||||
const { sendAlert } = require('./alertService');
|
const { sendAlert } = require('./alertService');
|
||||||
|
const { getMode, MODES } = require('./modeManager');
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
const visionConfig = config.vision?.humanDetection || {};
|
const visionConfig = config.vision?.humanDetection || {};
|
||||||
@@ -55,6 +56,11 @@ let latestPositiveFrame = null; // { cameraId, confidence, ts, buffer }
|
|||||||
let cooldownUntil = 0;
|
let cooldownUntil = 0;
|
||||||
let hasClearedSinceLastDiscord = true;
|
let hasClearedSinceLastDiscord = true;
|
||||||
|
|
||||||
|
function isDetectionActiveMode() {
|
||||||
|
const mode = getMode();
|
||||||
|
return mode !== MODES.ADMIN && mode !== MODES.LOCKDOWN;
|
||||||
|
}
|
||||||
|
|
||||||
function ensureCameraState(cameraId) {
|
function ensureCameraState(cameraId) {
|
||||||
if (!cameraState.has(cameraId)) {
|
if (!cameraState.has(cameraId)) {
|
||||||
cameraState.set(cameraId, {
|
cameraState.set(cameraId, {
|
||||||
@@ -135,6 +141,10 @@ function sendDiscordDetectionAlert(now) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function evaluateEpisode(now = Date.now()) {
|
function evaluateEpisode(now = Date.now()) {
|
||||||
|
if (!isDetectionActiveMode()) {
|
||||||
|
markCleared(now);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (episodeStartAt != null && lastAnyPositiveAt != null && now - lastAnyPositiveAt > CLEAR_WINDOW_MS) {
|
if (episodeStartAt != null && lastAnyPositiveAt != null && now - lastAnyPositiveAt > CLEAR_WINDOW_MS) {
|
||||||
markCleared(now);
|
markCleared(now);
|
||||||
return;
|
return;
|
||||||
@@ -271,6 +281,7 @@ if (!startWorker()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roomCameraStreamEvents.on('frame', ({ id, buffer, ts }) => {
|
roomCameraStreamEvents.on('frame', ({ id, buffer, ts }) => {
|
||||||
|
if (!isDetectionActiveMode()) return;
|
||||||
if (!id || !buffer) return;
|
if (!id || !buffer) return;
|
||||||
submitFrame(String(id), buffer, ts);
|
submitFrame(String(id), buffer, ts);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user