Detection
Welcome to the documentation about the detectors.
detector
Copyright (c) 2021-2022 UCLouvain, ICTEAM Licensed under GPL-3.0 [see LICENSE for details] Written by Jonathan Samelson (2021-2022)
- class Detector[source]
Bases:
abc.ABC
- abstract detect(org_frame: numpy.array) pytb.output.detection.Detection [source]
Performs an inference on the given frame.
- Parameters
org_frame (np.array) – The given frame to infer detections
- Returns
A set of detections of the detected objects
- Return type
detector_factory
Copyright (c) 2021-2022 UCLouvain, ICTEAM Licensed under GPL-3.0 [see LICENSE for details] Written by Jonathan Samelson (2021-2022), Arthur Pisvin (2023)
- class DetectorFactory[source]
Bases:
object
- static create_detector(proc_parameters: dict) pytb.detection.detector.Detector [source]
Creates a detector given a dictionary of parameters provided that the defined parameters are valid. Otherwise, an error message is given indicating the invalid parameters. Based on a model type and an implementation, it initializes the appropriate detector with the given parameters.
- Parameters
proc_parameters (dict) – A dictionary describing the detector to initialize.
- Returns
A concrete implementation of a Detector (e.g YOLO).
- Return type
- static _bboxes_2d_detector(proc_parameters: dict) pytb.detection.bboxes.bboxes_2d_detector.bboxes_2d_detector.BBoxes2DDetector [source]
Creates a BBoxes2DDetector given a dictionary of parameters. It then branches on the model type to initialize a concrete detector implementation (e.g YOLO).
detection_manager
Copyright (c) 2021-2022 UCLouvain, ICTEAM Licensed under GPL-3.0 [see LICENSE for details] Written by Jonathan Samelson (2021-2022)
- class DetectionManager(detector: pytb.detection.detector.Detector, preprocess_parameters: dict, postprocess_parameters: dict)[source]
Bases:
object
- __init__(detector: pytb.detection.detector.Detector, preprocess_parameters: dict, postprocess_parameters: dict)[source]
This class is used to handle all the steps of the detection in one single detect method. Specifically, it applies the preprocess parameters, infer the detections and filters out the results using the postprocess parameters. This constructor initialize a DetectionManager provided that the preprocess and post process parameters are valid. Otherwise, an error message is given indicating the invalid parameter(s).
- Parameters
detector (Detector) – A concrete implementation of a Detector initialized using the detector_factory.
preprocess_parameters (dict) – A dictionary containing the image transformation before proceeding to the detection.
postprocess_parameters (dict) – A dictionary containing the thresholds to filter out the results of the detection.
- Returns
An initialized DetectionManager that can be called on each frame using detect method.
- Return type
- detect(org_frame: numpy.ndarray) pytb.output.detection.Detection [source]
Proceeds to the detection on the given frame. It first transforms the image using the preprocess parameters of this instance of DetectionManager. Then, it infers the results of the detection (see the concrete implementation of the provided detector). Finally, it filters out the result using the postprocess parameters of this instance of DetectionManager.
bboxes_2d_detector
Hereby, you find two tables that (1) list the parameters in relation with the JSON config file that can be used for each detector and (2) give details on their usage.
Detector |
Parameters |
---|---|
BackgroundSubtractor (mean/median) |
|
BackgroundSubtractor (frame_diff) |
|
FasterRCNN / MaskRCNN |
|
YOLO4 (YOLOv 2, 3, 4) |
|
YOLO5 |
|
Detectron2 |
|
* In FasterRCNN and MAskRCNN: model_path is not needed in case use_coco_weights
is true.
Parameter |
Default value |
Description |
---|---|---|
|
/ |
The path to the weight of the model to be used (e.g. for YOLOv5, ending with .pt) |
|
/ |
The path to the configuration file describing the model |
|
416 |
The input path of the image in the detector. This allows to setup the first layers of the network to match the image shape. |
|
0 |
The minimum confidence threshold of the detected objects if the implementation allows to provide one. |
|
0 |
The minimum non-max suppression threshold of the detected objects when the implementation allows to provide one. |
|
true |
Whether to perform the NMS algorithm across the different classes of object or separately. |
|
false |
Whether to use the GPU if available. |
|
false |
Whether to use the half precision capability of the recent GPU cards. |
|
true |
Whether to use the default weights available on PyTorch. If True, it will be downloading in cache automatically. |
|
3 |
From cv2.approxPolyDP: Specifies the approximation accuracy. This is the maximum distance between the original curve and its approximation. |
|
50 |
The minimum intensity of the pixels in the foreground image. |
|
50 |
The number of last images that will be based to determine the brackground and the foreground (either with a mean or median computation) |
Copyright (c) 2021-2022 UCLouvain, ICTEAM Licensed under GPL-3.0 [see LICENSE for details] Written by Jonathan Samelson (2021-2022)
- class BBoxes2DDetector(proc_parameters: dict)[source]
Bases:
pytb.detection.detector.Detector
,abc.ABC
- __init__(proc_parameters: dict)[source]
This class encompasses the attributes that are common to most detectors of 2D bounding boxes. Initializes the detector with the given parameters.
- Parameters
proc_parameters (dict) – A dictionary containing the parameters of the desired detector.
- abstract detect(org_frame: numpy.array) pytb.output.bboxes_2d.BBoxes2D [source]
Performs an inference on the given frame.
- Parameters
org_frame (np.array) – The given frame to infer detections
- Returns
A set of 2D bounding boxes identifying detected objects of the detected objects
- Return type