bluecherrydvr / bluecherry-apps

Bluecherry surveillance system (server application)
http://www.bluecherrydvr.com
GNU General Public License v2.0
211 stars 68 forks source link

ONVIF event subscription: Return available list of event types supported by the camera #662

Open curtishall opened 7 months ago

curtishall commented 7 months ago

Currently the (old) onvif_tool (out of spec) only supported motion events. Edge based motion events (camera triggered motion events) are overly sensitive and really not that useful for customers when they can use our own motion detection built into our software already.

However more and more cameras, even cheap ones, are starting to support basic AI (person / vehicle / catdog / etc). We should expand on our existing nodejs onvif code base and detect the available event subscription options and return that when queried. In the web UI the end user can select the event type(s) to start recording (respecting the pre/post recording that we have now for onvif triggering (https://github.com/bluecherrydvr/bluecherry-apps/blob/31fdffcd61fc178c05da566cc66887937cf004f8/www/template/ajax/deviceschedule.php#L43)

The nodejs code returns the following when connecting to a ONVIF supported camera that has multiple event types:

Connected to ONVIF Device
Manufacturer  REOLINK
Model         RLC-823A
Firmware      v3.1.0.2831_23102509_v1.0.0.31
Serial Number 19216886176
Device Time   Wed Feb 21 2024 00:59:55 GMT+0000 (Coordinated Universal Time)
Found Event - /VIDEOSOURCE/MOTIONALARM
  Source={"simpleItemDescription":{"$":{"Name":"Source","Type":"tt:ReferenceToken"}}}
  Data={"simpleItemDescription":{"$":{"Name":"State","Type":"xsd:boolean"}}}
Found Event - /VIDEOSOURCE/IMAGETOODARK/IMAGINGSERVICE
  Source={"simpleItemDescription":{"$":{"Name":"Source","Type":"tt:ReferenceToken"}}}
  Data={"simpleItemDescription":{"$":{"Name":"State","Type":"xsd:boolean"}}}
Found Event - /MEDIA/PROFILECHANGED
  Data={"simpleItemDescription":{"$":{"Name":"Token","Type":"tt:ReferenceToken"}}}
Found Event - /MEDIA/CONFIGURATIONCHANGED
  Source={"simpleItemDescription":{"$":{"Name":"Token","Type":"tt:ReferenceToken"}}}
  Data={"simpleItemDescription":{"$":{"Name":"Type","Type":"xsd:string"}}}
Found Event - /RULEENGINE/CELLMOTIONDETECTOR/MOTION
  Source={"simpleItemDescription":[{"$":{"Name":"VideoSourceConfigurationToken","Type":"tt:ReferenceToken"}},{"$":{"Name":"VideoAnalyticsConfigurationToken","Type":"tt:ReferenceToken"}},{"$":{"Name":"Rule","Type":"xsd:string"}}]}
  Data={"simpleItemDescription":{"$":{"Name":"IsMotion","Type":"xsd:boolean"}}}

EVENT: 2024-02-21T00:59:55.000Z RuleEngine/CellMotionDetector/Motion PROP:Initialized SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=false
EVENT: 2024-02-21T00:59:55.000Z RuleEngine/MyRuleDetector/FaceDetect PROP:Initialized SRC:Source=VideoSourceToken DATA:State=false
EVENT: 2024-02-21T00:59:55.000Z RuleEngine/MyRuleDetector/PeopleDetect PROP:Initialized SRC:Source=VideoSourceToken DATA:State=false
EVENT: 2024-02-21T00:59:55.000Z RuleEngine/MyRuleDetector/VehicleDetect PROP:Initialized SRC:Source=VideoSourceToken DATA:State=false
EVENT: 2024-02-21T00:59:55.000Z RuleEngine/MyRuleDetector/DogCatDetect PROP:Initialized SRC:Source=VideoSourceToken DATA:State=false
EVENT: 2024-02-21T00:59:55.000Z VideoSource/MotionAlarm PROP:Initialized SRC:Source=000 DATA:State=false

When a person is detected:

EVENT: 2024-02-21T01:02:48.000Z RuleEngine/MyRuleDetector/PeopleDetect PROP:Changed SRC:Source=VideoSourceToken DATA:State=true

When the person is no longer detected:

EVENT: 2024-02-21T01:03:02.000Z RuleEngine/MyRuleDetector/PeopleDetect PROP:Changed SRC:Source=VideoSourceToken DATA:State=false

Note: The camera also throws motion detection too....we would encourage users NOT to select motion. Here is the motion alerts from the same event above:

EVENT: 2024-02-21T01:02:49.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=true
EVENT: 2024-02-21T01:02:49.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=true
EVENT: 2024-02-21T01:03:12.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=false
EVENT: 2024-02-21T01:03:12.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=false
EVENT: 2024-02-21T01:03:27.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=true
EVENT: 2024-02-21T01:03:27.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=true
EVENT: 2024-02-21T01:03:30.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=false
EVENT: 2024-02-21T01:03:30.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=false

Full log (all events pulled):

EVENT: 2024-02-21T01:02:48.000Z RuleEngine/MyRuleDetector/PeopleDetect PROP:Changed SRC:Source=VideoSourceToken DATA:State=true
EVENT: 2024-02-21T01:02:49.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=true
EVENT: 2024-02-21T01:02:49.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=true
EVENT: 2024-02-21T01:03:02.000Z RuleEngine/MyRuleDetector/PeopleDetect PROP:Changed SRC:Source=VideoSourceToken DATA:State=false
EVENT: 2024-02-21T01:03:12.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=false
EVENT: 2024-02-21T01:03:12.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=false
EVENT: 2024-02-21T01:03:27.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=true
EVENT: 2024-02-21T01:03:27.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=true
EVENT: 2024-02-21T01:03:30.000Z RuleEngine/CellMotionDetector/Motion PROP:Changed SRC:VideoSourceConfigurationToken=000 DATA:IsMotion=false
EVENT: 2024-02-21T01:03:30.000Z VideoSource/MotionAlarm PROP:Changed SRC:Source=000 DATA:State=false
andrey-utkin commented 6 months ago

@curtishall is that https://github.com/agsh/onvif/blob/master/examples/example6.js ? Do you have your own patches on top of that?

andrey-utkin commented 6 months ago

Let's take this https://github.com/agsh/onvif/blob/master/examples/example6.js ,

And then some frontend magic.

curtishall commented 6 months ago

@curtishall is that https://github.com/agsh/onvif/blob/master/examples/example6.js ? Do you have your own patches on top of that?

I do not

JahleelAbraham commented 6 months ago

Let's take this https://github.com/agsh/onvif/blob/master/examples/example6.js ,

  • tweak to take command line arguments for HOSTNAME, PASSWORD etc
  • make it figure out intelligently EVENT_RECEIVER_IP_ADDRESS, EVENT_RECEIVER_PORT from the host it's running on
  • give it a sensible name and put the changed script into misc/onvif/ alongside getRtspUrls.js and others

And then some frontend magic.

I'll get started working on that 👍🏾