Skip to main content

flydra_pt_detect_cfg/
lib.rs

1//! Default values for the [`ImPtDetectCfg`] type of the
2//! [`flydra-feature-detector-types`](https://crates.io/crates/flydra-feature-detector-types)
3//! crate.
4
5// Copyright 2020-2023 Andrew D. Straw.
6//
7// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
9// or http://opensource.org/licenses/MIT>, at your option. This file may not be
10// copied, modified, or distributed except according to those terms.
11
12use flydra_feature_detector_types::{ContrastPolarity, ImPtDetectCfg};
13use strand_http_video_streaming_types::Shape;
14
15fn my_default(polarity: ContrastPolarity, valid_region: Shape) -> ImPtDetectCfg {
16    ImPtDetectCfg {
17        do_update_background_model: true,
18        polarity,
19        alpha: 0.01,
20        n_sigma: 7.0,
21        bright_non_gaussian_cutoff: 255,
22        bright_non_gaussian_replacement: 5,
23        bg_update_interval: 200,
24        diff_threshold: 30,
25        use_cmp: true,
26        max_num_points: 1,
27        feature_window_size: 30,
28        clear_fraction: 0.3,
29        despeckle_threshold: 5,
30        valid_region,
31    }
32}
33
34/// Default configuration for detecting features brighter or darker than background
35pub fn default_absdiff() -> ImPtDetectCfg {
36    my_default(ContrastPolarity::DetectAbsDiff, Shape::Everything)
37}
38
39/// Default configuration for detecting features darker than background in a circular region of interest
40pub fn default_dark_circle() -> ImPtDetectCfg {
41    my_default(
42        ContrastPolarity::DetectDark,
43        Shape::Circle(strand_http_video_streaming_types::CircleParams {
44            center_x: 640,
45            center_y: 512,
46            radius: 512,
47        }),
48    )
49}