Case study

Motion Detection VMS

C# Windows app integrating ONVIF IP cameras with EmguCV motion detection and PTZ control.

  • C#
  • .NET
  • OpenCV
The core problem

What needed solving

Security operators needed a single Windows desktop tool to manage ONVIF IP cameras — connecting via RTSP, controlling PTZ movement, and detecting motion — without relying on vendor-specific software.

The solution

What I built

Implements ONVIF device management, media service queries, and PTZ control APIs directly from C#, combined with EmguCV frame-differencing for motion detection on live RTSP streams.

A C# WinForms desktop application that connects to ONVIF-compliant IP cameras via their device and media service endpoints. Uses EmguCV (OpenCV wrapper) for real-time motion detection, and implements continuous, absolute, and relative PTZ (pan-tilt-zoom) camera control over ONVIF + RTSP streams.

Integration

How it fits together

The WinForms app talks to cameras over ONVIF: the device service discovers media profiles, the media service provides RTSP stream URIs, and the PTZ service handles continuous, absolute, and relative moves. EmguCV (OpenCV for .NET) runs frame differencing on the live RTSP feed, and an FFMPEG forwarding module supports running as a Windows service.

The flow, step by step

  1. Enter the camera IP address, port, username, and password (or paste an RTSP URL for auto-parsing).
  2. Connect to the ONVIF device service to discover media profiles and stream URIs.
  3. Use PTZ controls (continuous, absolute, relative move) to position the camera.
  4. Start motion detection to run EmguCV frame differencing on the live RTSP stream.
Problems along the way

What got hard, and what I did about it

Vendor lock-in

The problem

Each camera brand ships its own management software.

What I did

Implemented the ONVIF standard directly in C#, so any compliant camera works through one tool.

Messy connection details

The problem

Operators have credentials and RTSP URLs in inconsistent formats.

What I did

Added RTSP URL auto-parsing alongside manual IP/port/credential entry.

Takeaways

What I learned

  • Building against an open standard pays off across hardware you have never tested.
  • Simple frame differencing is a great start, but false positives are the real problem to solve next.
Outcome

Where it stands today

ONVIF device management and media service integration for IP camera discovery.
PTZ control: continuous, absolute, relative move, and configuration retrieval via ONVIF.
RTSP URL parsing and EmguCV-powered real-time motion detection on live camera feeds.
Windows service support via FFMPEG stream forwarding module.

Milestones

  • ONVIF camera integration

    Device management, media profiles, and RTSP stream connection via ONVIF service endpoints.

    Shipped
  • PTZ control

    Continuous, absolute, and relative PTZ move commands implemented via ONVIF PTZ API.

    Shipped
  • EmguCV motion detection

    Real-time frame differencing on RTSP streams using EmguCV (C# OpenCV wrapper).

    Shipped
  • Alert classification

    Sensitivity tuning and object classification improvements are future work.

    Planned

Next up

  • Add motion event history logging and clip saving.
  • Improve false-positive reduction with background subtraction models.
  • Expand to multi-camera grid views.