def track_min_objects(video_info): previous_frame = None previous_num_obj = -1 tracked_video = [] frame_id = 0 min_rects = [] min_frame_id = None min_num_obj = None for frame_info in video_info: if (min_num_obj is None) & (len(frame_info.rects) > 0): min_num_obj = len(frame_info.rects) min_frame_id = frame_id if (len(frame_info.rects) < min_num_obj) & (len(frame_info.rects) > 0): min_num_obj = len(frame_info.rects) min_frame_id = frame_id frame_id = frame_id + 1 min_rects = multiclass_rectangle.duplicate_rects( video_info[min_frame_id].rects) ("Min num object video:%d" % min_num_obj) for frame_info in video_info: print("Tracking Frame Nr: %d" % frame_info.frame) print("Len Rects Frame: %d" % len(frame_info.rects)) current_frame = frame.Frame_Info() current_frame = frame_info.duplicate() current_frame.rects = [] if previous_frame is not None: print("Min num object video:%d" % min_num_obj) print("Len Previous Rects Frame: %d" % len(previous_frame.rects)) for rect in previous_frame.rects: print(len(current_frame.rects)) if len(current_frame.rects) <= min_num_obj: current_rect = multiclass_rectangle.pop_max_iou( frame_info.rects, rect) current_rect.load_trackID(rect.trackID) current_frame.append_labeled_rect(current_rect) else: trackID = 1 for rect in min_rects: if len(current_frame.rects) < min_num_obj: current_rect = multiclass_rectangle.pop_max_iou( frame_info.rects, rect) current_rect.load_trackID(trackID) current_frame.append_labeled_rect(current_rect) trackID = trackID + 1 previous_frame = current_frame.duplicate() previous_frame.rects = multiclass_rectangle.duplicate_rects( current_frame.rects) print("Current Frame obj:%d" % len(current_frame.rects)) tracked_video.insert(len(tracked_video), current_frame) return tracked_video
def track_min_objects(video_info): previous_frame= None previous_num_obj=-1 tracked_video=[] frame_id=0 min_rects=[] min_frame_id=None min_num_obj=None for frame_info in video_info: if (min_num_obj is None) & (len(frame_info.rects) >0): min_num_obj = len(frame_info.rects) min_frame_id=frame_id if (len(frame_info.rects) < min_num_obj ) & (len(frame_info.rects) >0): min_num_obj = len(frame_info.rects) min_frame_id=frame_id frame_id=frame_id+1 min_rects = multiclass_rectangle.duplicate_rects(video_info[min_frame_id].rects) print "Min num object video:%d"%min_num_obj for frame_info in video_info: print "Tracking Frame Nr: %d"%frame_info.frame print "Len Rects Frame: %d"%len(frame_info.rects) current_frame = frame.Frame_Info() current_frame=frame_info.duplicate() current_frame.rects=[] if previous_frame is not None: print "Min num object video:%d"%min_num_obj print "Len Previous Rects Frame: %d"%len(previous_frame.rects) for rect in previous_frame.rects: print len(current_frame.rects) if len(current_frame.rects)<=min_num_obj: current_rect = multiclass_rectangle.pop_max_iou(frame_info.rects,rect) current_rect.load_trackID(rect.trackID) current_frame.append_labeled_rect(current_rect) else: trackID=1 for rect in min_rects: if len(current_frame.rects)<min_num_obj: current_rect = multiclass_rectangle.pop_max_iou(frame_info.rects,rect) current_rect.load_trackID(trackID) current_frame.append_labeled_rect(current_rect) trackID=trackID+1 previous_frame=current_frame.duplicate() previous_frame.rects= multiclass_rectangle.duplicate_rects(current_frame.rects) print "Current Frame obj:%d"%len(current_frame.rects) tracked_video.insert(len(tracked_video), current_frame) return tracked_video
def track_objects(video_info): previous_frame = None previous_num_obj = -1 tracked_video = [] for frame_info in video_info: print("Tracking Frame Nr: %d" % frame_info.frame) print("Len Rects Frame: %d" % len(frame_info.rects)) current_frame = frame.Frame_Info() current_frame = frame_info.duplicate() current_frame.rects = [] if previous_frame is not None: print("Len Previous Rects Frame: %d" % len(previous_frame.rects)) for rect in previous_frame.rects: print(len(current_frame.rects)) current_rect = multiclass_rectangle.pop_max_iou( frame_info.rects, rect) current_rect.load_trackID(rect.trackID) current_frame.append_labeled_rect(current_rect) else: trackID = 1 picked_rect = Utils_Tensorbox.NMS(frame_info.rects) for rect in picked_rect: current_rect = rect.duplicate() current_rect.load_trackID(trackID) current_frame.append_labeled_rect(current_rect) trackID = trackID + 1 previous_frame = current_frame.duplicate() previous_frame.rects = multiclass_rectangle.duplicate_rects( current_frame.rects) print("Current Frame obj:%d" % len(current_frame.rects)) tracked_video.insert(len(tracked_video), current_frame) return tracked_video
def track_objects(video_info): previous_frame= None previous_num_obj=-1 tracked_video=[] for frame_info in video_info: print "Tracking Frame Nr: %d"%frame_info.frame print "Len Rects Frame: %d"%len(frame_info.rects) current_frame = frame.Frame_Info() current_frame=frame_info.duplicate() current_frame.rects=[] if previous_frame is not None: print "Len Previous Rects Frame: %d"%len(previous_frame.rects) for rect in previous_frame.rects: print len(current_frame.rects) current_rect = multiclass_rectangle.pop_max_iou(frame_info.rects,rect) current_rect.load_trackID(rect.trackID) current_frame.append_labeled_rect(current_rect) else: trackID=1 picked_rect=Utils_Tensorbox.NMS(frame_info.rects) for rect in picked_rect: current_rect = rect.duplicate() current_rect.load_trackID(trackID) current_frame.append_labeled_rect(current_rect) trackID=trackID+1 previous_frame=current_frame.duplicate() previous_frame.rects= multiclass_rectangle.duplicate_rects(current_frame.rects) print "Current Frame obj:%d"%len(current_frame.rects) tracked_video.insert(len(tracked_video), current_frame) return tracked_video
def recurrent_track_objects(video_info): previous_frame= None previous_num_obj=-1 tracked_video=[] deltas_video=[] deltas_frame=[] dx1,dx2,dy1,dy2=0,0,0,0 for frame_info in video_info: print "Tracking Frame Nr: %d"%frame_info.frame print "Len Rects Frame: %d"%len(frame_info.rects) current_frame = frame.Frame_Info() current_frame=frame_info.duplicate() current_frame.rects=[] if previous_frame is not None: deltas_frame=[] if frame_info.frame>1: print "Len Previous Rects Frame: %d"%len(previous_frame.rects) rect_idx=0 for rect in previous_frame.rects: print len(current_frame.rects) rect.add_delta(deltas_video[frame_info.frame-2][rect_idx][0],deltas_video[frame_info.frame-2][rect_idx][1],deltas_video[frame_info.frame-2][rect_idx][2],deltas_video[frame_info.frame-2][rect_idx][3]) current_rect = multiclass_rectangle.pop_max_iou(frame_info.rects,rect) if current_rect is not None: current_rect.load_trackID(rect.trackID) current_rect.check_rects_motion(frame_info.filename, rect, deltas_video[frame_info.frame-2][rect_idx][0],deltas_video[frame_info.frame-2][rect_idx][1],deltas_video[frame_info.frame-2][rect_idx][2],deltas_video[frame_info.frame-2][rect_idx][3]) current_frame.append_labeled_rect(current_rect) dx1=current_rect.x1-rect.x1 dx2=current_rect.x2-rect.x2 dy1=current_rect.y1-rect.y1 dy2=current_rect.y2-rect.y2 deltas_frame.append((dx1,dx2,dy1,dy2)) else: break else: print "Len Previous Rects Frame: %d"%len(previous_frame.rects) for rect in previous_frame.rects: print len(current_frame.rects) current_rect = multiclass_rectangle.pop_max_iou(frame_info.rects,rect) if current_rect is not None: dx1=current_rect.x1-rect.x1 dx2=current_rect.x2-rect.x2 dy1=current_rect.y1-rect.y1 dy2=current_rect.y2-rect.y2 deltas_frame.append((dx1,dx2,dy1,dy2)) current_rect.load_trackID(rect.trackID) current_frame.append_labeled_rect(current_rect) else: break deltas_video.append(deltas_frame) else: trackID=1 picked_rect=Utils_Tensorbox.NMS(frame_info.rects) for rect in picked_rect: current_rect = rect.duplicate() current_rect.load_trackID(trackID) current_frame.append_labeled_rect(current_rect) trackID=trackID+1 previous_frame=current_frame.duplicate() previous_frame.rects= multiclass_rectangle.duplicate_rects(current_frame.rects) print "Current Frame obj:%d"%len(current_frame.rects) tracked_video.insert(len(tracked_video), current_frame) return tracked_video
def recurrent_track_objects(video_info): previous_frame = None previous_num_obj = -1 tracked_video = [] deltas_video = [] deltas_frame = [] dx1, dx2, dy1, dy2 = 0, 0, 0, 0 for frame_info in video_info: print("Tracking Frame Nr: %d" % frame_info.frame) print("Len Rects Frame: %d" % len(frame_info.rects)) current_frame = frame.Frame_Info() current_frame = frame_info.duplicate() current_frame.rects = [] if previous_frame is not None: deltas_frame = [] if frame_info.frame > 1: print("Len Previous Rects Frame: %d" % len(previous_frame.rects)) rect_idx = 0 for rect in previous_frame.rects: print(len(current_frame.rects)) rect.add_delta( deltas_video[frame_info.frame - 2][rect_idx][0], deltas_video[frame_info.frame - 2][rect_idx][1], deltas_video[frame_info.frame - 2][rect_idx][2], deltas_video[frame_info.frame - 2][rect_idx][3]) current_rect = multiclass_rectangle.pop_max_iou( frame_info.rects, rect) if current_rect is not None: current_rect.load_trackID(rect.trackID) current_rect.check_rects_motion( frame_info.filename, rect, deltas_video[frame_info.frame - 2][rect_idx][0], deltas_video[frame_info.frame - 2][rect_idx][1], deltas_video[frame_info.frame - 2][rect_idx][2], deltas_video[frame_info.frame - 2][rect_idx][3]) current_frame.append_labeled_rect(current_rect) dx1 = current_rect.x1 - rect.x1 dx2 = current_rect.x2 - rect.x2 dy1 = current_rect.y1 - rect.y1 dy2 = current_rect.y2 - rect.y2 deltas_frame.append((dx1, dx2, dy1, dy2)) else: break else: print("Len Previous Rects Frame: %d" % len(previous_frame.rects)) for rect in previous_frame.rects: print(len(current_frame.rects)) current_rect = multiclass_rectangle.pop_max_iou( frame_info.rects, rect) if current_rect is not None: dx1 = current_rect.x1 - rect.x1 dx2 = current_rect.x2 - rect.x2 dy1 = current_rect.y1 - rect.y1 dy2 = current_rect.y2 - rect.y2 deltas_frame.append((dx1, dx2, dy1, dy2)) current_rect.load_trackID(rect.trackID) current_frame.append_labeled_rect(current_rect) else: break deltas_video.append(deltas_frame) else: trackID = 1 picked_rect = Utils_Tensorbox.NMS(frame_info.rects) for rect in picked_rect: current_rect = rect.duplicate() current_rect.load_trackID(trackID) current_frame.append_labeled_rect(current_rect) trackID = trackID + 1 previous_frame = current_frame.duplicate() previous_frame.rects = multiclass_rectangle.duplicate_rects( current_frame.rects) print("Current Frame obj:%d" % len(current_frame.rects)) tracked_video.insert(len(tracked_video), current_frame) return tracked_video