zma gets --dry-run, --json, --zone and --set. With them it re-analyses an
event without changing anything, analyses only the chosen zone as an
Active zone, replaces its detection settings for the run, and prints each
frame's alarmed/filtered/blob counts and boxes as JSON lines. The zone is
rebuilt through Zone::LoadRow, pulled out of Zone::Load, so percentages
convert exactly as at capture time. CheckAlarms records the boxes in a
ZoneDiagnostics member on Zone, kept off ZoneStats since that is copied
into every packet.
The zone editor gets a test panel under the image. It runs zma on a picked
or typed event with the form's unsaved settings (web/ajax/zone.php checks
permissions, validates every value and allows one run per monitor), then
replays the event - mp4 or its JPEG frames - with zma's outlines, min vs
got for each check up to the first that fails, and a timeline of which
frames alarm. Min/Max, MinBlobs, OverloadFrames and the alarm frame count
are judged in the browser, so changing them needs no re-run.
The object box is saved with the zone in a new Zones.ObjectCoords column
(zm_update-1.39.53.sql) and drawn again when the zone is reopened.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EventStream::loadEventData and zma both joined the DefaultVideo column
onto the event path and opened the result, so a DefaultVideo containing
../ made zms stream, or zma read and hard link, files outside the event
directory. Reduce it to std::filesystem::path::filename() when loading.
zma also wrote the value back into a new event's row with plain
string formatting; escape it with zmDbEscapeString.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 18f48f8bc95f53d0b21110f2f5e5a2c9d22c9a9b)
mysql_insert_id() returns my_ulonglong, but zmDbDoInsert() returned int.
Once Events.Id passed INT32_MAX the id was truncated, then sign-extended
when stored in Event::id (uint64_t), so 3502167073 became
18446744072916751373. The Events_Hour/Day/Week/Month inserts were given
the negative value and rejected, and every later UPDATE of the event
matched no row.
Also widen the callers that re-truncated the result: the re-analysis
event id in zma, Tag::Id() when building an Event_Tag, and
Event_Tag::save(). The Events_* insert format specifiers become PRIu64
to match the unsigned id.
fixes#4974
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BV1gDc9T6D6H8gtTcxwLvk
getpid() requires explicit inclusion of <unistd.h> on FreeBSD where
transitive includes from other headers are not guaranteed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a new zma binary that re-analyses recorded events using current zone
settings. It decodes frames from stored video (FFmpeg) or JPEG files and
runs the full motion detection pipeline (DetectMotion + ref_image blending
+ state machine).
Two modes of operation:
- Default: updates the original event's motion stats (AlarmFrames,
TotScore, AvgScore, MaxScore) in the database
- --create-events (-c): creates new events from detected motion regions,
with video files hard linked (copy fallback) to the new event directory
Additional features:
- --save-analysis (-a): writes analysis JPEGs with zone alarm overlays
to the event directory for visual inspection
- --monitor (-m): override which monitor's zone config to use
- --verbose (-v): increase debug verbosity
Adds Monitor::AnalyseFrame() public methods that encapsulate DetectMotion
+ ref_image initialization and blending, with an optional analysis_image
output parameter for zone overlay rendering. Also guards shared_data
access in DetectMotion to allow offline use without shared memory.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds fifo options for diagnostic images for much lower impact diagnostics mode. Diagnostic images are only written when there is a client listening for them (otherwise they are skipped). Also added a json stream for the detection data so you can see in real time the pixels or blobs detected for the motion. This allows for easy real time stream of both delta and reference images (as video streams) along with the detection numbers.