DynAIkonTrap.filtering.animal#

This module provides a generic interface to an animal detector. The system is fairly agnostic of the specific animal detection mechanism beings used, as the input to the AnimalFilter is a JPEG, RGB or RGBA image and the output a confidence in the image containing an animal.

The animal detection model may be chosen from a range of pre-trained detector networks, configurable via AnimalFilterSettings. Choices currently range between: a SSDLite MobileNet v2 model trained on WCS data, int32 quantised, a SSDLite MobileNet v2 model trained on human and WCS data, int32 quantised and a YOLOv4-tiny model trained on WCS data

The function, AnimalFilter.run() produces a tuple result, the first result indicates animal presence; the second result human presence. If the model used is trained on WCS data only, the second result will always be False

Classes

AnimalFilter(settings[, sender_settings])

Animal filter stage to indicate if a frame contains an animal

CompressedImageFormat(value)

Class to store supported compressed image formats

NetworkInputSizes()

A class to hold data for neural network input buffer sizes.

class AnimalFilter(settings: AnimalFilterSettings, sender_settings: Optional[SenderSettings] = None)#

Animal filter stage to indicate if a frame contains an animal

Parameters

settings (AnimalFilterSettings) – Settings for the filter

run(image: bytes, is_jpeg: bool = False) Tuple[bool, bool]#

The same as run_raw(), but with a threshold applied. This function outputs a boolean to indicate if the confidences are at least as large as the threshold

Parameters
  • image (bytes) – The image frame to be analysed, can be in JPEG compressed format or YUV420 raw format

  • is_jpeg (bool, optional) – used to inform buffer reading, set to True if a jpeg is given, False for YUV420 buffer. Defaults to False.

Returns

Each element is True if the confidence is at least the threshold, otherwise False. Elements represent detections for animal and human class.

Return type

Tuple(bool, bool)

run_raw(image: bytes, is_jpeg: bool = False) Tuple[float, float]#

Run the animal filter on the image to give a confidence that the image frame contains an animal and/or a human. For configurations where an animal-only detector is initialised, human confidence will always equal 0.0.

Parameters
  • image (bytes) – The image frame to be analysed, can be in JPEG compressed format or YUV420 raw format

  • is_jpeg (bool, optional) – used to inform buffer reading, set to True if a jpeg is given, False for YUV420 buffer. Defaults to False.

Returns

Confidences in the output containing an animal and a human as a decimal fraction in range (0-1)

Return type

Tuple(float, float)

run_raw_fcc(image: bytes, is_jpeg: bool = False) float#

A function to run the animal detection method by querying the FASTCAT-Cloud Web API

Parameters
  • image (bytes) – The image frame to be analysed, can be in JPEG compressed format or YUV420 raw format

  • is_jpeg (bool, optional) – used to inform buffer reading, set to True if a jpeg is given, False for YUV420 buffer. Defaults to False.

Returns

The score of the highest confidence animal bounding box, as returned by FASTCAT-Cloud API

Return type

float

class CompressedImageFormat(value)#

Class to store supported compressed image formats

JPEG = 0#
class NetworkInputSizes#

A class to hold data for neural network input buffer sizes. Sizes are in (width, height) format

SSDLITE_MOBILENET_V2 = (300, 300)#
YOLOv4_TINY = (416, 416)#