DynAIkonTrap.settings#

The mechanism by which the tunable settings may be loaded into the system. Whilst this may look complicated at first, it provides a simple method to access all of the settings without needing to index into/get from a dictionary. This also means IDEs are able to perform autocompletion and provide type hints as the settings are unpacked in their respective places in the system.

To load the settings.json file, just run the load_settings() function once and it returns the a Settings object. For example:

settings = load_settings()

camera = DynAIkonTrap.camera.Camera(settings=settings.camera)

The settings.json should ideally be generated by the provided tuner.py script, although manual modifications may be desired.

The JSON file should be structured as follows (of course the values can be changed):

{
    "pipeline": {
        "pipeline_variant": 1
    },
    "camera": {
        "framerate": 20,
        "resolution": [
            1920,
            1080
        ]
    },
    "filter": {
        "motion": {
            "small_threshold": 10,
            "sotv_threshold": 5398.984990821726,
            "iir_cutoff_hz": 1.2400793650793651,
            "iir_order": 3,
            "iir_attenuation": 35
        },
        "animal": {
            "animal_threshold": 0.8,
            "detect_humans": true,
            "human_threshold": 0.8,
            "fast_animal_detect": true
        },
        "processing": {
            "smoothing_factor": 0.5,
            "max_sequence_period_s": 10.0,
            "context_length_s": 3.0,
            "detector_fraction": 1.0
        }
    },
    "sensor": {
        "port": "/dev/ttyUSB0",
        "baud": 57600,
        "interval_s": 30.0,
        "obfuscation_distance_km": 2
    },
    "output": {
        "path": "output",
        "output_mode": 0,
        "output_format": 0,
        "device_id": 0
    },
    "logging": {
        "level": "INFO",
        "path": "/dev/stdout"
    },
    "version": "1.2.2"
}

Functions

get_setting(setting)

get_settings_path()

load_settings()

Call this function once to load the settings from settings.json file.

save_settings(settings)

serialise(obj)

set_setting(setting, value)

get_setting(setting: str) str#
get_settings_path()#
load_settings() Settings#

Call this function once to load the settings from settings.json file. If the file is not present some defaults are loaded.

NOTE: these defaults should not be used for anything other than a brief test. Please generate a settings.json for any full deployments (see docs for more info).

Returns:

The settings for all tunable parameters in the system.

Return type:

Settings

save_settings(settings)#
serialise(obj)#
set_setting(setting: str, value: str)#

Classes

AnimalFilterSettings([fastcat_cloud_detect, ...])

Settings for a AnimalFilter

CameraSettings([framerate, resolution])

Settings for Camera and CameraToDisk

FilterSettings([motion, animal, processing])

Settings for a Filter

LoggerSettings([level, path])

Settings for logging

MotionFilterSettings([area_reality, ...])

Settings for a MotionFilter

OutputFormat(value)

System output format

OutputMode(value)

System output mode

OutputSettings([device_id, output_format, ...])

Base-class of settings for outputting to disk or server uploads

PipelineSettings([pipeline_variant])

Settings for which video processing pipeline to use

PipelineVariant(value)

An enumeration.

ProcessingSettings([smoothing_factor, ...])

Settings for MotionQueue and DynAIkonTrap.filtering.filtering.Filter

SenderSettings([device_id, output_format, ...])

Settings for a Sender

SensorSettings([port, baud, interval_s, ...])

Settings for a SensorLogs

Settings([pipeline, camera, filter, sensor, ...])

Settings for the camera trap system.

class AnimalFilterSettings(fastcat_cloud_detect: bool = False, animal_threshold: float = 0.75, detect_humans: bool = True, human_threshold: float = 0.75, fast_animal_detect: bool = True)#

Settings for a AnimalFilter

animal_threshold: float = 0.75#
detect_humans: bool = True#
fast_animal_detect: bool = True#
fastcat_cloud_detect: bool = False#
human_threshold: float = 0.75#
class CameraSettings(framerate: int = 20, resolution: Tuple[int, int] = (1920, 1080))#

Settings for Camera and CameraToDisk

framerate: int = 20#
resolution: Tuple[int, int] = (1920, 1080)#
class FilterSettings(motion: MotionFilterSettings = MotionFilterSettings(area_reality=0.0064, subject_distance=1.0, animal_speed=1.0, focal_len=0.0036, pixel_size=1.4e-06, num_pixels=2592, small_threshold=10, sotv_threshold=5400.0, iir_cutoff_hz=1.25, iir_order=3, iir_attenuation=35), animal: AnimalFilterSettings = AnimalFilterSettings(fastcat_cloud_detect=False, animal_threshold=0.75, detect_humans=True, human_threshold=0.75, fast_animal_detect=True), processing: ProcessingSettings = ProcessingSettings(smoothing_factor=0.5, max_sequence_period_s=10.0, context_length_s=3.0, detector_fraction=1.0))#

Settings for a Filter

animal: AnimalFilterSettings = AnimalFilterSettings(fastcat_cloud_detect=False, animal_threshold=0.75, detect_humans=True, human_threshold=0.75, fast_animal_detect=True)#
motion: MotionFilterSettings = MotionFilterSettings(area_reality=0.0064, subject_distance=1.0, animal_speed=1.0, focal_len=0.0036, pixel_size=1.4e-06, num_pixels=2592, small_threshold=10, sotv_threshold=5400.0, iir_cutoff_hz=1.25, iir_order=3, iir_attenuation=35)#
processing: ProcessingSettings = ProcessingSettings(smoothing_factor=0.5, max_sequence_period_s=10.0, context_length_s=3.0, detector_fraction=1.0)#
class LoggerSettings(level: str = 'INFO', path: str = '/builds/dynaikontrap/dynaikontrap/docs/log.txt')#

Settings for logging

level: str = 'INFO'#
path: str = '/builds/dynaikontrap/dynaikontrap/docs/log.txt'#
class MotionFilterSettings(area_reality: float = 0.0064, subject_distance: float = 1.0, animal_speed: float = 1.0, focal_len: float = 0.0036, pixel_size: float = 1.4e-06, num_pixels: int = 2592, small_threshold: int = 10, sotv_threshold: float = 5400.0, iir_cutoff_hz: float = 1.25, iir_order: int = 3, iir_attenuation: int = 35)#

Settings for a MotionFilter

animal_speed: float = 1.0#
area_reality: float = 0.0064#
focal_len: float = 0.0036#
iir_attenuation: int = 35#
iir_cutoff_hz: float = 1.25#
iir_order: int = 3#
num_pixels: int = 2592#
pixel_size: float = 1.4e-06#
small_threshold: int = 10#
sotv_threshold: float = 5400.0#
subject_distance: float = 1.0#
update(camera_settings: CameraSettings)#
class OutputFormat(value)#

System output format

STILL = 1#
VIDEO = 0#
class OutputMode(value)#

System output mode

DISK = 0#
SEND = 1#
class OutputSettings(device_id: Any = 0, output_format: OutputFormat = 0, output_mode: OutputMode = 0, path: str = '/builds/dynaikontrap/dynaikontrap/docs/output', delete_metadata: bool = 1)#

Base-class of settings for outputting to disk or server uploads

delete_metadata: bool = 1#
device_id: Any = 0#
output_format: OutputFormat = 0#
output_mode: OutputMode = 0#
path: str = '/builds/dynaikontrap/dynaikontrap/docs/output'#
class PipelineSettings(pipeline_variant: PipelineVariant = 1)#

Settings for which video processing pipeline to use

pipeline_variant: PipelineVariant = 1#
class PipelineVariant(value)#

An enumeration.

LEGACY = 0#
LOW_POWER = 1#
class ProcessingSettings(smoothing_factor: float = 0.5, max_sequence_period_s: float = 10.0, context_length_s: float = 3.0, detector_fraction: float = 1.0)#

Settings for MotionQueue and DynAIkonTrap.filtering.filtering.Filter

context_length_s: float = 3.0#
detector_fraction: float = 1.0#
max_sequence_period_s: float = 10.0#
smoothing_factor: float = 0.5#
class SenderSettings(device_id: Any = 0, output_format: OutputFormat = 0, output_mode: OutputMode = 0, path: str = '/builds/dynaikontrap/dynaikontrap/docs/output', delete_metadata: bool = 1, is_fcc: bool = 0, server: str = 'https://backend.fastcat-cloud.org', POST: str = '/api/v2/predictions/demo', userId: str = '', apiKey: str = '', modelId: str = 'f4a2d089-9b92-453d-985d-604ce6915703')#

Settings for a Sender

POST: str = '/api/v2/predictions/demo'#
apiKey: str = ''#
is_fcc: bool = 0#
modelId: str = 'f4a2d089-9b92-453d-985d-604ce6915703'#
server: str = 'https://backend.fastcat-cloud.org'#
userId: str = ''#
class SensorSettings(port: str = '/dev/ttyUSB0', baud: int = 57600, interval_s: float = 30.0, obfuscation_distance_km: float = 2)#

Settings for a SensorLogs

The obfuscation_distance should be kept to the range [0..`EARTH_CIRCUMFERENCE_KM/8`), otherwise it will internally be capped to this range. Note that setting to less than 1mm will be rounded down to zero.

baud: int = 57600#
interval_s: float = 30.0#
obfuscation_distance_km: float = 2#
port: str = '/dev/ttyUSB0'#
class Settings(pipeline: PipelineSettings = PipelineSettings(pipeline_variant=1), camera: CameraSettings = CameraSettings(framerate=20, resolution=(1920, 1080)), filter: FilterSettings = FilterSettings(motion=MotionFilterSettings(area_reality=0.0064, subject_distance=1.0, animal_speed=1.0, focal_len=0.0036, pixel_size=1.4e-06, num_pixels=2592, small_threshold=10, sotv_threshold=5400.0, iir_cutoff_hz=1.25, iir_order=3, iir_attenuation=35), animal=AnimalFilterSettings(fastcat_cloud_detect=False, animal_threshold=0.75, detect_humans=True, human_threshold=0.75, fast_animal_detect=True), processing=ProcessingSettings(smoothing_factor=0.5, max_sequence_period_s=10.0, context_length_s=3.0, detector_fraction=1.0)), sensor: SensorSettings = SensorSettings(port='/dev/ttyUSB0', baud=57600, interval_s=30.0, obfuscation_distance_km=2), output: Union[SenderSettings, OutputSettings] = SenderSettings(device_id=0, output_format=0, output_mode=0, path='/builds/dynaikontrap/dynaikontrap/docs/output', delete_metadata=1, is_fcc=0, server='https://backend.fastcat-cloud.org', POST='/api/v2/predictions/demo', userId='', apiKey='', modelId='f4a2d089-9b92-453d-985d-604ce6915703'), logging: LoggerSettings = LoggerSettings(level='INFO', path='/builds/dynaikontrap/dynaikontrap/docs/log.txt'), version: str = '1.5.1')#

Settings for the camera trap system. A class of nested classes and variables to represent all tunable parameters in the system.

camera: CameraSettings = CameraSettings(framerate=20, resolution=(1920, 1080))#
filter: FilterSettings = FilterSettings(motion=MotionFilterSettings(area_reality=0.0064, subject_distance=1.0, animal_speed=1.0, focal_len=0.0036, pixel_size=1.4e-06, num_pixels=2592, small_threshold=10, sotv_threshold=5400.0, iir_cutoff_hz=1.25, iir_order=3, iir_attenuation=35), animal=AnimalFilterSettings(fastcat_cloud_detect=False, animal_threshold=0.75, detect_humans=True, human_threshold=0.75, fast_animal_detect=True), processing=ProcessingSettings(smoothing_factor=0.5, max_sequence_period_s=10.0, context_length_s=3.0, detector_fraction=1.0))#
logging: LoggerSettings = LoggerSettings(level='INFO', path='/builds/dynaikontrap/dynaikontrap/docs/log.txt')#
output: Union[SenderSettings, OutputSettings] = SenderSettings(device_id=0, output_format=0, output_mode=0, path='/builds/dynaikontrap/dynaikontrap/docs/output', delete_metadata=1, is_fcc=0, server='https://backend.fastcat-cloud.org', POST='/api/v2/predictions/demo', userId='', apiKey='', modelId='f4a2d089-9b92-453d-985d-604ce6915703')#
pipeline: PipelineSettings = PipelineSettings(pipeline_variant=1)#
sensor: SensorSettings = SensorSettings(port='/dev/ttyUSB0', baud=57600, interval_s=30.0, obfuscation_distance_km=2)#
version: str = '1.5.1'#