Contains a C++ framework for motion detection. More...
Data Structures | |
| class | Detector |
| Motion detector. More... | |
| struct | Event |
| An event generated by Simd::Motion::Detector on the current frame. More... | |
| struct | Metadata |
| Result of Detector::NextFrame for the current frame. More... | |
| struct | Model |
| Scene model used to calibrate Simd::Motion::Detector. More... | |
| struct | Object |
| A classified moving object on the current frame. More... | |
| struct | Options |
| Options used by Simd::Motion::Detector. More... | |
| struct | Position |
| Position of a detected object at one timestamp. More... | |
Typedefs | |
| typedef double | Time |
| Time in seconds. Typical usage copies Frame::timestamp (OpenCV CAP_PROP_POS_MSEC * 0.001). | |
| typedef int | Id |
| Object identifier. Object::id and Event::objectId; -1 if the event is not linked to an object. | |
| typedef std::string | String |
| Text type. Event::text and the result of ToString(). | |
| typedef Simd::Point< ptrdiff_t > | Size |
| Screen size in pixels (width and height). | |
| typedef Simd::Point< ptrdiff_t > | Point |
| Screen point in pixels (x and y). Origin is the top-left corner. Typical usage is Object::trajectory[].point and DrawLine. | |
| typedef std::vector< Point > | Points |
| Vector of screen points. | |
| typedef Simd::Rectangle< ptrdiff_t > | Rect |
| Screen rectangle in pixels. Typical usage is Object::rect for DrawRectangle. | |
| typedef Simd::Point< double > | FSize |
| ONVIF size (width and height) in range [0, 2]. Model::size; default (0.1, 0.1) is about 0.25% of the screen area. | |
| typedef Simd::Point< double > | FPoint |
| ONVIF point (x and y) in range [-1, 1]. Origin is the screen center; X grows right, Y grows up. Used by Model::roi. | |
| typedef std::vector< FPoint > | FPoints |
| Vector of ONVIF points. Model::roi polygon. | |
| typedef Simd::View< Simd::Allocator > | View |
| Image type. Typical usage wraps OpenCV cv::Mat as Frame input and annotates Object::rect on it. | |
| typedef Simd::Frame< Simd::Allocator > | Frame |
| Video frame. Typical usage is Frame(image, false, timestampInSeconds) as NextFrame input. | |
| typedef std::vector< Position > | Positions |
| Object::trajectory. Typical usage iterates from 1 to size()-1 and draws lines. | |
| typedef std::vector< Object > | Objects |
| Metadata::objects: classified moving objects, including those that disappeared on this frame. | |
| typedef std::vector< Event > | Events |
| Metadata::events of the current frame. Typical usage iterates them after objects. | |
Functions | |
| SIMD_INLINE double | ScreenToOnvifX (ptrdiff_t x, ptrdiff_t screenWidth) |
| Converts a screen X-coordinate to an ONVIF X-coordinate. More... | |
| SIMD_INLINE double | ScreenToOnvifY (ptrdiff_t y, ptrdiff_t screenHeight) |
| Converts a screen Y-coordinate to an ONVIF Y-coordinate. More... | |
| SIMD_INLINE FPoint | ScreenToOnvif (const Point &point, const Point &screenSize) |
| Converts screen 2D-coordinates to ONVIF 2D-coordinates. More... | |
| SIMD_INLINE FSize | ScreenToOnvifSize (const Size &size, const Point &screenSize) |
| Converts a screen 2D-size to an ONVIF 2D-size. More... | |
| SIMD_INLINE ptrdiff_t | OnvifToScreenX (double x, ptrdiff_t screenWidth) |
| Converts an ONVIF X-coordinate to a screen X-coordinate. More... | |
| SIMD_INLINE ptrdiff_t | OnvifToScreenY (double y, ptrdiff_t screenHeight) |
| Converts an ONVIF Y-coordinate to a screen Y-coordinate. More... | |
| SIMD_INLINE Point | OnvifToScreen (const FPoint &point, const Point &screenSize) |
| Converts ONVIF 2D-coordinates to screen 2D-coordinates. More... | |
| SIMD_INLINE Size | OnvifToScreenSize (const FSize &size, const Point &screenSize) |
| Converts an ONVIF 2D-size to a screen 2D-size. More... | |
| SIMD_INLINE String | ToString (Id id) |
| Converts an object ID to a string. More... | |
Detailed Description
Contains a C++ framework for motion detection.
This is a wrapper around the low-level Motion Detection API.
Typical usage creates a Detector, optionally calls SetModel and SetOptions once, then for every video frame wraps a View as Frame with a timestamp in seconds and calls NextFrame. NextFrame fills Metadata with classified moving objects and events (Event::ObjectIn, Event::ObjectOut, Event::SabotageOn, Event::SabotageOff).
The example annotates Metadata on the input image: DrawRectangle around Object::rect, ToString(Object::id) above the box, DrawLine along Object::trajectory, and a scrolling list of Event::type / Event::objectId. Red marks objects that have an event in the same frame.
SetModel and SetOptions are typically called once before the video loop. Calibration (pyramid scale and ROI mask) runs on the first NextFrame and when the input size changes. The shooting-star example (disabled by #if 0) uses a small Model::size and lowered ClassificationShiftMin / ClassificationTimeMin. A Gray8 Model::mask can restrict ROI (non-zero pixels are inside). Debug annotation is drawn on an optional Bgr24 output Frame of the same size as input.
ONVIF coordinates place the origin at the screen center: X in [-1, 1] (left to right), Y in [-1, 1] with +Y up. Screen coordinates are pixels with (0, 0) at the top-left.
Using example (motion detection in the video captured by OpenCV):