You hit my soft spot. I haven't tested this, but it should give you what you want, except for conditional handling of the events.
#!/usr/bin/env python
import camect
import requestsimport time
import datetime
def handle_event(evt):
print_event(evt)
send_to_axis(evt)
def send_to_axis(evt):
def print_event(evt):
print ('{}: {}'.format(datetime.datetime.now(), evt))
if __name__ == '__main__':
camect.Home(
'camect_hostname_or_ip',
'camect_local_user_name',
'camect_local_password'
).add_event_listener(
lambda event: handle_event(event)
)
while True:
# keep running while events trigger
time.sleep( 5 )
Event objects are dictionaries that currently look something like the following. You'll probably be most interested in the "cam_name", "type", and "detected_obj" keys. For "type", you'll be interested in when it is "alert", rather than "mode" and "detected_obj" will contain a list of the detected objects that you can operate on. There's also an "roi" key that contains the boundary of the detected object, which I removed for brevity.
{
"cam_id": "abcdef0123456789abcd",
"cam_name": "camera name",
"desc": "camera name just saw a USPS truck.",
"detected_obj": [
"USPS truck"
],
"type": "alert",
}