offlinemot.objects_classes.TrafficObj

class offlinemot.objects_classes.TrafficObj(frame, frame_id, box, track_id, config=<config.configs object>, tracker=<built-in function TrackerKCF_create>, class_id=-1, detection_way=1, detect_prob=0.0)[source]

A class used to represent any traffic entity, with its full track across frame until it gets lost.

…

Variables
  • ~TrafficObj.box (list) – a box is list of [x,y,w,h] where x,y is the top-left point coordinates and w,h are the width and height of the bounding box unrotated.

  • ~TrafficObj.boxes (list) – a list of box lists for every time step saved in time_steps

  • ~TrafficObj.true_wh_max (tuple) – the width and height when the object is moving horizontally, vertically or the nearst to these directions

  • ~TrafficObj.tracking_state (list) – the list of the tracking success variable

  • ~TrafficObj.time_steps (list) – list of frames where object is tested for detection or tracking.

  • ~TrafficObj.trust_level (list) – list of three values rows where each value refer to a boolean, indicating the sucess of detection, tracking and background subtraction respectively

  • ~TrafficObj.tracker_class (Tracker function) – The function that will build the tracker object (default: TrackerKCF_create)

  • ~TrafficObj.tracker (Tracker object) – the tracker object that will perform the tracking

  • ~TrafficObj.class_id (int) – an integer representing the type of object whether it is -1: unknown (default), 1 pedistrains, 2 cyclist, 3 cars.

  • ~TrafficObj.colors_map (list) – what color to draw each traffic object

  • ~TrafficObj.track_id (int) – a unique id assigned to each traffic object

  • ~TrafficObj.last_detect_prob (float) – the probabilty of the last detection. it is needed to solve overlaping conflict (default:0)

  • ~TrafficObj.img_wh (tuple) – the width and height of the frame

  • ~TrafficObj.angels (list) – a placeholder list to calculate the angle of direction at the end for the object.

  • ~TrafficObj.centers (list) – a placeholder list to calculate the centers of the boxes at the end for the object.

find_center()[source]

Calculate the current center for the box. the output is integers

track(new_frame, frame_id)[source]

Track the object in the new frame, save the result, and update the true size

re_init_tracker(frame)[source]

start a new tracker object in the frame provided with the current box

draw(new_frame=numpy array)[source]

Draw the current box position with color code and track ID on the frame

update()[source]

Test the object if still need to be tracked, or it is lost so if it needs to be deleted

filter_by_detections_dist(detections, check=False)[source]

It assigns the object to one of the detections in the frame if a minimum distance and detection probability is found.

filter_by_bg_objs(bg_objs)[source]

check if the object is within a minimum distance to any moving area.

set_detection(ok)[source]

save the result of the current detection.

set_bg_substract(ok)[source]

save the result of the current background subtraction.

set_track_id(id_)[source]

set track id for the object once it has a detected class

find_true_size(new_box)[source]

Test evey box of the current position whether it moves in the horizontal or vertical direction or the closest to that and save the current size if so.

get_detection_format()[source]

Get the bounding box in (top-left point, bottom-right) point format and add class_id and dummy probabilty.