def csrt_create(bounding_box, frame):
    #print(bounding_box)
    tracker = cv2.TrackerCSRT_create()
    tracker.init(frame, tuple(bounding_box))
    blob = Blob(bounding_box, tracker)
    #print(blob)
    return blob
DETECTION_FRAME_RATE = 48
MAX_CONSECUTIVE_TRACKING_FAILURES = 15

def get_bounding_boxes(_frame):
    fullbody_cascade = cv2.CascadeClassifier('./HaarCascades/fullbody.xml')
    gray = cv2.cvtColor(_frame, cv2.COLOR_BGR2GRAY)
    _bounding_boxes = fullbody_cascade.detectMultiScale(gray)
    return _bounding_boxes

# initialize trackers and create new blobs
_, frame = cap.read()
initial_bboxes = get_bounding_boxes(frame)
for box in initial_bboxes:
    tracker = cv2.TrackerCSRT_create()
    tracker.init(frame, tuple(box))
    _blob = Blob(box, tracker)
    blobs[blob_id] = _blob

while True:
    if cap.get(cv2.CAP_PROP_POS_FRAMES) + 1 < cap.get(cv2.CAP_PROP_FRAME_COUNT):
        _, frame = cap.read()
        
        # update trackers
        for _id, blob in list(blobs.items()):
            success, box = blob.tracker.update(frame)
            if success:
                blob.num_consecutive_tracking_failures = 0
                blob.update(box)

                # draw and label bounding boxes
                (x, y, w, h) = [int(v) for v in box]
def csrt_create(bounding_box, frame):
    tracker = cv2.TrackerCSRT_create()
    tracker.init(frame, tuple(bounding_box[0:4]))
    blob = Blob(bounding_box, tracker)
    return blob
示例#4
0
def csrt_create(bounding_box, frame, vehicle_type):
    tracker = cv2.TrackerCSRT_create()
    tracker.init(frame, tuple(bounding_box))
    blob = Blob(bounding_box, tracker, vehicle_type)
    return blob
def csrt_create(bounding_box, vehicle_type, type_confidence, frame):
    tracker = cv2.TrackerCSRT_create()
    tracker.init(frame, tuple(bounding_box))
    blob = Blob(bounding_box, vehicle_type, type_confidence, tracker)
    return blob
def kcf_create(bounding_box, frame):
    tracker = cv2.TrackerKCF_create()
    tracker.init(frame, tuple(bounding_box))
    blob = Blob(bounding_box, tracker)
    return blob