DynAIkonTrap.camera_to_disk#

This module handles detection and recording of motion events to disk. This interfaces with DynCamera to buffer streams of vectors, H264 data and a raw stream.

Motion detection is performed within MotionRAMBuffer by filtering each motion vectors for each frame using MotionFilter. When motion is detected, the buffers are emptied to a location on disk for further processing.

An output queue of emptied buffer directories is accessible via the output of CameraToDisk.

Classes

CameraToDisk(camera_settings, ...)

Wraps DynCamera functionality to stream motion events to disk.

DirectoryMaker(base_dir)

Creates new directories for storing motion events.

PiMotionAnalysis()

class CameraToDisk(camera_settings: CameraSettings, writer_settings: OutputSettings, filter_settings: FilterSettings)#

Wraps DynCamera functionality to stream motion events to disk.

Initialiser, creates instance of camera and buffers for catching it’s output.

Parameters:
  • camera_settings (CameraSettings) – settings object for camera construction

  • writer_settings (WriterSettings) – settings object for writing out events

  • filter_settings (FilterSettings) – settings object for filter parameters

capture_still(filename: str, fmt='image/jpeg')#

Captures a still image on the video port, can be called while the camera is recording. Insipred by picamera example: https://picamera.readthedocs.io/en/release-1.13/recipes2.html#capturing-images-whilst-recording :param filename: filename to save capture to, jpg. :type filename: str

empty_all_buffers(current_path: str, start: bool)#

Switches and empties all three buffers. Switching is performed near-simultaneously. Writing may take longer.

Parameters:
  • current_path (Path) – directory to write events

  • start (bool) – True if start of a new motion event, False otherwise.

get() str#
record()#

Function records streams from the camera to RAM buffers. When motion is detected, buffers are emptied in three stages. 1) motion occurs, initial buffers are emptied to fill context time. Here an event is started on disk. 2) while motion continues and the length of the event is smaller than the max. event length continue writing to disk and swapping buffers as they become full. 3) motion has ended, continue recording for a trail-off period equal to the context length. Finally switch buffers and empty one last time.

When a motion event finishes, it’s saved directory is added to the output queue.

class DirectoryMaker(base_dir: str)#

Creates new directories for storing motion events.

Takes a base directory and initialises a DirectoryMaker for motion events.

Parameters:

base_dir (str) – base directory for storing motion events.

new_event() str#

Gives the string name for a new directory on disk. If a new directory cannot be made in the conventional way (by appending to a counter), then a directory in the /tmp location is created and returned instead.

class PiMotionAnalysis#