PyFastTrack package
Detector
- class pyfasttrack.base_detector.BaseDetector
Bases:
object
Abstract class to implement an objects detector.
- abstract detect(image)
Abstract method to be implemented.
This method will take a full image with all the objects to detect and will return a list of tuples (mask, left_corner_coordinate [x, y]) with one object by mask, the object represented by non-zero pixels and the background by zero pixels.
Parameters
- imagendarray
The full image.
Returns
- dict
List of (mask, left_corner_coord).
- get_direction(mask, features)
Get the object direction.
The object orientation is updated with the correct direction.
Parameters
- maskndarray
Mask of one object.
- featuresdict
Object features.
Returns
- bool
Is object left oriented.
- ndarray
Rotated mask.
- ndarray
Rotation matrix.
- get_features(mask)
Get the object features using equivalent ellipse.
Parameters
- maskndarray
Mask of one object.
- class pyfasttrack.ft_detector.FtDetector(params)
Bases:
BaseDetector
Implement the classic FastTrack detector.
- class pyfasttrack.yolo_detector.YoloDetector(params)
Bases:
BaseDetector
Tracker
- class pyfasttrack.tracker.Tracker(params=None, detector=None)
Bases:
object
Tracker class to determine assignment from previous and current coordinates.
- static angle_difference(a, b)
Get the minimal difference, a-b), between two angles.
Parameters
- afloat
First angle.
- bfloat
Second angle.
Returns
- float
a-b.
- assign(prev, current)
Find the optimal assignent.
Parameters
- prevlist
List of dict. Each dict is one object with 4 key “0”, “1”, “2”, “3”. 0,1,2 is the {center, orientation} of the head, tail and body respectively. 3 is {area, perim} of the object.
- currentlist
List of dict. Each dict is one object with 4 key “0”, “1”, “2”, “3”. 0,1,2 is the {center, orientation} of the head, tail and body respectively. 3 is {area, perim} of the object.
Returns
- list
Assignment.
- clean(current, counter, lost, idty)
Delete objects that were lost. Only counter is copied in this function. Other lists act as pointer.
Parameters
- currentlist
List to clean.
- counterlist
Counter of losses.
- lostlist
Lost objects.
- idtylist
Objects’ identity
Returns
- list
Cleaned list.
- list
Updated counter.
- compute_cost(var, norm)
Compute the cost.
Parameters
- varList
List of variable.
- normlist
Normalization coefficient associated to var.
Returns
- float
Cost.
- static div(a, b)
Division by zero, a/0=0.
Parameters
- afloat
Dividend.
- bfloat
Divisor.
Returns
- float
a/b.
- find_lost(assignment)
Find object lost at previous step.
Parameters
- assignmentlist
Assignment indexes.
Returns
- list
Indexes of lost objects.
- initialize(image)
Initialize the tracker.
Parameters
- imagendarray
Image, channels depending on the detector.
Returns
- list
List of detected objects as dict.
- process(image)
Process an image.
Parameters
- imagendarray
Image, channels depending on the detector.
Returns
- list
List of detected objects as dict.
- reassign(past, current, order)
Reassign current based on order.
Parameters
- prevlist
List of dict of previous detections.
- currentlist
List of dict of current detections.
- orderlist
Reassingment
Returns
- list
Reordered current.
Data
- class pyfasttrack.data.Configuration
Bases:
object
Class to read and write configuration files compatible with FastTrack.
- get_keys(keys)
Get parameters from their keys.
Parameters
- keyslist
List of keys.
Returns
- List
Parameters.
- read_db(path)
Read a configuration file from database.
Parameters
- pathstr
Path pointing to the sqlite database.
Returns
- Dict
Parameters.