mirror of
https://github.com/koush/scrypted.git
synced 2026-07-08 08:10:37 +01:00
videoanalysis: add analyze button
This commit is contained in:
4
plugins/core/package-lock.json
generated
4
plugins/core/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.0.153",
|
||||
"version": "0.0.154",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.0.153",
|
||||
"version": "0.0.154",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@koush/wrtc": "^0.5.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.0.153",
|
||||
"version": "0.0.154",
|
||||
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
@change="save"
|
||||
:class="lazyValue.description ? 'mb-2' : ''"
|
||||
></v-checkbox>
|
||||
<div v-if="lazyValue.type === 'button'" @click="save">
|
||||
<v-btn small block> {{ lazyValue.title }} </v-btn>
|
||||
<span v-if="lazyValue.description" class="caption pl-1">{{ lazyValue.description }}</span>
|
||||
</div>
|
||||
<v-combobox
|
||||
v-else-if="lazyValue.choices && lazyValue.combobox"
|
||||
dense
|
||||
@@ -129,7 +133,8 @@ export default {
|
||||
booleanValue: {
|
||||
get() {
|
||||
return (
|
||||
this.lazyValue.value && this.lazyValue.value.toString().toLowerCase() === "true"
|
||||
this.lazyValue.value &&
|
||||
this.lazyValue.value.toString().toLowerCase() === "true"
|
||||
);
|
||||
},
|
||||
set(val) {
|
||||
|
||||
4
plugins/objectdetector/package-lock.json
generated
4
plugins/objectdetector/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/objectdetector",
|
||||
"version": "0.0.26",
|
||||
"version": "0.0.27",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/objectdetector",
|
||||
"version": "0.0.26",
|
||||
"version": "0.0.27",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/objectdetector",
|
||||
"version": "0.0.26",
|
||||
"version": "0.0.27",
|
||||
"description": "Scrypted Video Analysis Plugin. Installed alongside a detection service like OpenCV or TensorFlow.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -115,7 +115,7 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
|
||||
detectionId: this.detectionId,
|
||||
settings: await this.getCurrentSettings(),
|
||||
});
|
||||
this.objectsDetected(detections);
|
||||
this.objectsDetected(detections, true);
|
||||
}
|
||||
|
||||
bindObjectDetection() {
|
||||
@@ -218,7 +218,7 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
|
||||
}
|
||||
}
|
||||
|
||||
async objectsDetected(detectionResult: ObjectsDetected) {
|
||||
async objectsDetected(detectionResult: ObjectsDetected, showAll?: boolean) {
|
||||
// do not denoise
|
||||
if (this.hasMotionType) {
|
||||
return;
|
||||
@@ -247,45 +247,14 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
|
||||
});
|
||||
if (found.length) {
|
||||
this.console.log('new detection:', found.map(d => `${d.detection.className} (${d.detection.score}, ${d.detection.id})`).join(', '));
|
||||
}
|
||||
if (found.length || showAll) {
|
||||
this.console.log('current detections:', this.currentDetections.map(d => `${d.detection.className} (${d.detection.score}, ${d.detection.id})`).join(', '));
|
||||
if (detectionResult.running)
|
||||
this.extendedObjectDetect();
|
||||
}
|
||||
}
|
||||
|
||||
async peopleDetected(detectionResult: ObjectsDetected) {
|
||||
if (!detectionResult?.people) {
|
||||
return;
|
||||
}
|
||||
|
||||
const found: DenoisedDetectionEntry<FaceRecognitionResult>[] = [];
|
||||
denoiseDetections<FaceRecognitionResult>(this.currentPeople, detectionResult.people.map(detection => ({
|
||||
id: detection.id,
|
||||
name: detection.label,
|
||||
detection,
|
||||
})), {
|
||||
timeout: this.detectionTimeout * 1000,
|
||||
added: d => found.push(d),
|
||||
removed: d => {
|
||||
this.console.log('expired detection:', `${d.detection.label} (${d.detection.score}, ${d.detection.id})`);
|
||||
if (detectionResult.running)
|
||||
this.extendedFaceDetect();
|
||||
}
|
||||
});
|
||||
if (found.length) {
|
||||
this.console.log('new detection:', found.map(d => `${d.detection.label} (${d.detection.score}, ${d.detection.id})`).join(', '));
|
||||
this.console.log('current detections:', this.currentDetections.map(d => `${d.detection.className} (${d.detection.score}, ${d.detection.id})`).join(', '));
|
||||
this.extendedFaceDetect();
|
||||
}
|
||||
}
|
||||
|
||||
async extendedFaceDetect() {
|
||||
this.objectDetection?.detectObjects(undefined, {
|
||||
detectionId: this.detectionId,
|
||||
duration: 60000,
|
||||
});
|
||||
}
|
||||
|
||||
setDetection(detectionId: string, detectionInput: DetectionInput) {
|
||||
// this.detections.set(detectionId, detectionInput);
|
||||
// setTimeout(() => {
|
||||
@@ -398,11 +367,22 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.hasMotionType) {
|
||||
settings.push(
|
||||
{
|
||||
title: 'Analyze',
|
||||
description: 'Analyzes the video stream for 1 minute. Results will be shown in the Console.',
|
||||
key: 'analyzeButton',
|
||||
type: 'button',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
async putMixinSetting(key: string, value: string | number | boolean): Promise<void> {
|
||||
const vs = value.toString();
|
||||
const vs = value?.toString();
|
||||
this.storage.setItem(key, vs);
|
||||
if (key === 'detectionDuration') {
|
||||
this.detectionDuration = parseInt(vs) || defaultDetectionDuration;
|
||||
@@ -423,6 +403,11 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
|
||||
else if (key === 'streamingChannel') {
|
||||
this.bindObjectDetection();
|
||||
}
|
||||
else if (key === 'analyzeButton') {
|
||||
this.snapshotDetection();
|
||||
this.startVideoDetection();
|
||||
this.extendedObjectDetect();
|
||||
}
|
||||
else {
|
||||
const settings = await this.getCurrentSettings();
|
||||
if (settings && settings[key]) {
|
||||
|
||||
Reference in New Issue
Block a user