Remove active objects when they become stationary

This commit is contained in:
Nicolas Mowen 2024-02-08 08:13:11 -07:00
parent 1fe950f55b
commit 5c52a1be7e
2 changed files with 13 additions and 9 deletions

View File

@ -152,12 +152,12 @@ export default function LivePlayer({
}
return (
<div className={`relative flex justify-center ${className}`}>
<div className={`relative flex justify-center w-full ${className}`}>
{(showStillWithoutActivity == false || activeMotion || activeTracking) &&
player}
{showStillWithoutActivity && !liveReady && (
<div className="absolute left-0 top-0 right-0 bottom-0">
<div className="absolute left-0 top-0 right-0 bottom-0 w-full">
<AutoUpdatingCameraImage
className="w-full h-full"
camera={cameraConfig.name}
@ -166,7 +166,7 @@ export default function LivePlayer({
fitAspect={
cameraConfig.detect.width / cameraConfig.detect.height > 2 ||
cameraConfig.detect.width / cameraConfig.detect.height < 1
? undefined
? cameraConfig.detect.width / cameraConfig.detect.height
: 16 / 9
}
/>

View File

@ -34,22 +34,26 @@ export default function useCameraActivity(
return;
}
if (event.type == "end") {
const eventIndex = activeObjects.indexOf(event.after.id);
if (event.type == "end") {
if (eventIndex != -1) {
const newActiveObjects = [...activeObjects];
newActiveObjects.splice(eventIndex, 1);
setActiveObjects(newActiveObjects);
}
} else {
if (!event.after.stationary) {
const eventIndex = activeObjects.indexOf(event.after.id);
if (eventIndex == -1) {
// add unknown event to list if not stationary
if (!event.after.stationary) {
const newActiveObjects = [...activeObjects, event.after.id];
setActiveObjects(newActiveObjects);
}
} else {
// remove known event from list if it has become stationary
if (event.after.stationary) {
activeObjects.splice(eventIndex, 1);
}
}
}
}, [event, activeObjects]);