Use ONVIF camera motion events to drive AI Port analysis and preserve a whole motion episode

Open
#121 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@itsmepetrov is already working on this.

Since Dec 4, 2026.

  • #127 by @itsmepetrov — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
machine-learning, python

Research direction

The implementation is already prepared in pull request #127, so review that pull request before starting work. Trace discovery of the ONVIF motion property and camera video input, then verify motion-state subscription, idle fallback to frame motion, and reconnect behavior. The expected result is one preserved motion episode with appropriate object classifications and recording boundaries.

Written by the indexing model from the issue text.

Description

accepted

I’m running Keystone’s virtual AI Port with UniFi Protect 7.3.74. Some of my cameras are exposed through an ONVIF bridge that already sends tns1:VideoSource/MotionAlarm when motion starts and stops.

I compared the bridge and Keystone logs for the same footage. In one 35-second motion interval, Keystone opened a vehicle event, closed it, then opened a person event. On a bird-feeder camera, the bridge reported motion while YOLOX-tiny stayed below the detection threshold on the full frame. In both cases, I’d like to be able to review the whole period of activity.

Proposed behavior and field results

The implementation is ready for review in #127. With aiport.camera_motion_events: auto, the AI Port checks each paired third-party camera for a supported motion property and a single identifiable video input. Once the camera reports its state, Keystone analyzes the existing stream during motion. During confirmed idle it continues recording and servicing the tracker without running object or face inference. Cameras with no verified source use frame motion. Once a camera has supplied a valid state, Keystone remembers that choice for the pairing. After a disconnect it retries the subscription and waits for a fresh camera state before resuming inference. Setting the option to off or YAML false selects frame motion for every camera.

On Protect 7.3.74, a classified interval can produce one smart card containing several observed object classes. A completed interval with no classified object can produce one ordinary motion card if Protect enables a full-frame motion zone. Protect applies its own padding. During the pilot I observed a person and a vehicle in one smart card. After enabling automatic discovery on all eight bridge cameras, a 10.46-second interval produced one ordinary card with the configured two seconds of recording on either side. Its boundaries were within 66 ms of the requested window. A subsequent motion-only card also served the square scene thumbnail and the full-view JPEG to Protect while keeping the recording boundaries.

These field observations used an ONVIF bridge and a real Protect console. Reports from physical ONVIF cameras would help establish interoperability.

Related issue

In #146, one person received multiple tracker IDs and thumbnails, and the walk was split into several events. Camera motion boundaries can help with event splitting when the source reports one continuous interval. Matching a person to the same track across frames and reducing duplicate thumbnails within one event are separate tracker work covered by #146.

Dominant language
Python
Stars
1k
Forks
114
Avg merge
1h
Merged PRs (30d)
115

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seeARMS/keystone

All issues in seeARMS/keystone

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.