Module DynAIkonTrap.comms

An interface for sending animal frames to a server. The Sender combines a frame with the most appropriate sensor log and sends these together via a HTTP POST request to the specified server.

The current server API is:

  • Path: /trap/capture

  • Type: POST

  • Files: The image frame encoded as JPEG

  • Data: meta-data for the image reporesented in the following JSON:

meta = {
            'trap_id': self._device_id,
            'time': time,
            'temperature': temp,
            'pressure': press,
            'brightness': light,
            'humidity': humidity,
        }

Classes

class Output (settings: OutputSettings, read_from: Tuple[FilterSensorLogs])

A base class to use for outputting captured images or videos. The output_still() and output_video() functions should be overridden with output method-specific implementations.

Subclasses

Methods

def close(self)
def output_still(self, image: bytes, time: float, **kwargs)

Output a still image with its sensor data. The sensor data can be provided via the keyword arguments.

Args

image : bytes
The JPEG image frame
time : float
UNIX timestamp when the image was captured
**humidity : float
Humidity at or close to capture time
**brightness : float
Brightness at or close to capture time
**pressure : float
Pressure at or close to capture time
**temperature : float
Temperature at or close to capture time
**trap_id
ID of the camera trap

Raises

NotImplementedError
A subclass should implement this function for the specific use-case e.g. writing to disk.
def output_video(self, video: IO[bytes], caption: _io.StringIO, time: float, **kwargs)

Output a video with its meta-data. The sensor data is provided via the video captions (caption).

Args

video : IO[bytes]
MP4 video (codec: H264 - MPEG-4 AVC (part 10))
caption : StringIO
WebVTT caption of sensor readings
time : float
UNIX timestamp when the image was captured

Raises

NotImplementedError
A subclass should implement this function for the specific use-case e.g. writing to disk.
class Sender (settings: SenderSettings, read_from: Tuple[FilterSensorLogs])

The Sender is a simple interface for sending the desired data to a server

Ancestors

Inherited members

class VideoCaption (sensor_logs: SensorLogs, framerate: float)

Class to aid in generating captions for video output. The captions are based on the logged sensor readings.

Args

sensor_logs : SensorLogs
The object containing the log of sensor readings
framerate : float
Camera framerate

Methods

def generate_vtt_for(self, timestamps: List[float]) ‑> _io.StringIO

Generate WebVTT captions containing the sensor readings at given moments in time.

Args

timestamps : List[float]
Timestamps for every frame in the motion/animal sequence

Returns

StringIO
The WebVTT captions ready to be sent to a server
class Writer (settings: WriterSettings, read_from: Tuple[FilterSensorLogs])

A base class to use for outputting captured images or videos. The output_still() and output_video() functions should be overridden with output method-specific implementations.

Ancestors

Inherited members