Feature Request (Multiple Action Triggers)

I’ve been using Security Spy for over 8 years and currently my system consists of:

  • M1 MacMini 
  • dedicated Gigabit POE network
  • 2 Hikvision Fisheye (H264@6MP)
  • 6 Hikvision (H265@4MP)
  • 6 Hikvision (ColorVu) (H265@8MP)
  • 1 Hikvision PTZ (LPR) (H265@4MP)
  • 1 Dahua PTZ (auto tracking) (H265@4MP)
  • 1 Reolink Doorbell (H264@5MP)


Typically the resource usage is minimal and for storage I use:


  • 1 x 6TB WD Purple via USB 3 and this allows me to get 90 days of AI Events on all cameras. 

I also keep 14 days rolling in B2 Cloud Storage which has been surprisingly robust for almost realtime backups.

I run various Home Automation via another server and heavily use the run script action to provide realtime alerting based on AI detections via sending HTTP requests directly from SecuritySpy.


To achieve the granular control i require, I have duplicated some cameras to allow a different URL to be called for both vehicle and human detections and this works relatively well.


I have these duplicated cameras deselected in the web server settings and no recording setup on the duplicates only AI actions. Initially I was of the impression that the duplicated cameras would cause minimal overhead from a decoding prospective due to Security Spy only needing to decode the stream once but lately I’ve been receiving periodic decoder overload errors.


Whereas this never occurred prior to the duplicate cameras being added. I’ve since assigned these duplicate cameras to the software encoder (being sure to match the encoder of the original) and this works, with CPU showing minimum 30% idle, but I do get some dropped frames/choppiness in recorded footage. 


**Feature Request**

It would be great if I could specify different actions based on each AI Trigger specially human and vehicle.

any tips would be greatly appreciated.

Comments

  • Duplicating cameras will not contribute towards the license limit, nor will it cause extra data streams to be pulled over the network, however it can cause extra decoding to happen, depending on your settings. So I believe this explains what you are seeing in terms of decoding overload problems (since the M1 chips have a somewhat limited ability to decode video data in hardware).

    It sounds like you can avoid this by adding a check to your script that checks the AI detection result, and taking different actions depending on which objects were detected. This should allow you to remove the duplicate camera instances. A few different parameters are passed into AppleScripts that are invoked as Actions - here is a simple example of how to obtain these in the script:

    on run args
    	set camNumber to item 1 of args
    	set camName to item 2 of args
    	set reasons to item 3 of args
    	
    	...
    
    end run
    

    For example, if the reason for the trigger was human detection, the "reasons" variable would be set to "Human". If both a human and vehicle is detected, this would be "Human,Vehicle".

  • Ben, thanks for the speedy reply!

    Looks fantastic,

    I can see how leveraging AppleScript would be perfect here, although admittedly the syntax is something i'm not familiar with. Apologies if it's already mentioned somewhere, i checked the example scripts and manual but couldn't figure out how to invoke a shell script conditionally.

    Example of something I'm trying to achieve:

    ***

    on run args

       set cameraNum to item 1 of args

       set cameraName to item 2 of args

       set reasons to item 3 of args


    If reasons="Human":

    do shell script "curl --insecure -X GET "https://10.0.2.8:7001/api/createEvent?source=CAM-04-STREET&caption=Video%20Analytics&description=Person" -H  "accept: */*" -H  "Authorization: Bearer XXXX-XXXX-XXXX-XXXX-XXXX""


    If reasons="Vehicle":

    do shell script "curl --insecure -X GET "https://10.0.2.8:7001/api/createEvent?source=CAM-04-STREET&caption=Video%20Analytics&description=Vehicle" -H  "accept: */*" -H  "Authorization: Bearer XXXX-XXXX-XXXX-XXXX""


    end run

    ***

    This is what is in my usual 'Run Shell Command' Box within the UI (works perfectly):

    "curl --insecure -X GET "https://10.0.2.8:7001/api/createEvent?source=CAM-04-STREET&caption=Video%20Analytics&description=Person" -H "accept: */*" -H "Authorization: Bearer XXXX-XXXX-XXXX-XXXX-XXXX"

    How would you format this one?

    Also, is the [""] double quotation marks a problem within AppleScript?


    Kind Regards,


    Joshua

  • If you have quotes within quotes, the inner ones have to be escaped with a \" sequence. So try this:

    set url_h to "curl --insecure -X GET \"https://10.0.2.8:7001/api/createEvent?source=CAM-04-STREET&caption=Video%20Analytics&description=Person\" -H \"accept: */*\" -H \"Authorization: Bearer XXXX-XXXX-XXXX-XXXX-XXXX\""
    
    if reasons contains "Human" then
    	do shell script url_h
    end if