videoanalysis: stream watchdog

This commit is contained in:
Koushik Dutta
2022-01-20 21:19:23 -08:00
parent f92fb81d97
commit fa6989cdbb
8 changed files with 17 additions and 9 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/objectdetector",
"version": "0.0.40",
"version": "0.0.41",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/objectdetector",
"version": "0.0.40",
"version": "0.0.41",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/objectdetector",
"version": "0.0.40",
"version": "0.0.41",
"description": "Scrypted Video Analysis Plugin. Installed alongside a detection service like OpenCV or TensorFlow.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -236,6 +236,7 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
this.running = session.running;
}
catch (e) {
this.console.log('failure retrieving stream', e);
this.running = false;
}
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/opencv",
"version": "0.0.36",
"version": "0.0.37",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/opencv",
"version": "0.0.36",
"version": "0.0.37",
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
}

View File

@@ -30,5 +30,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.0.36"
"version": "0.0.37"
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/tensorflow-lite",
"version": "0.0.30",
"version": "0.0.31",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/tensorflow-lite",
"version": "0.0.30",
"version": "0.0.31",
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
}

View File

@@ -37,5 +37,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.0.30"
"version": "0.0.31"
}

View File

@@ -93,6 +93,7 @@ class DetectionSession:
self.attached = False
self.mutex = multiprocessing.Lock()
self.valve: PipelineValve = None
self.last_sample = time.time()
def clearTimeoutLocked(self):
if self.timerHandle:
@@ -210,6 +211,10 @@ class DetectPlugin(scrypted_sdk.ScryptedDeviceBase, ObjectDetection):
detection_session.future.add_done_callback(
lambda _: self.end_session(detection_session))
if detection_session and time.time() - detection_session.last_sample > 30:
print('detection session has not received a sample in 30 seconds, terminating', detection_session.id)
ending = True
if ending:
if detection_session:
self.end_session(detection_session)
@@ -303,6 +308,8 @@ class DetectPlugin(scrypted_sdk.ScryptedDeviceBase, ObjectDetection):
first_frame = True
def user_callback(gst_sample, src_size, convert_to_src_size):
try:
detection_session.last_sample = time.time()
nonlocal first_frame
if first_frame:
first_frame = False