Пример #1
0
def main():
	global tracker
	global msg
	msg = IntList()
	global inverse_cam_matrix, cam_to_quad, tcam
    #Initialize ROS node
	rospy.init_node('sort_tracker', anonymous=False)
	rate = rospy.Rate(10)

	# Get the parameters
	global camera_parameters
	(camera_topic, detection_topic, tracker_topic, cost_threshold, max_age, min_hits,camera_parameters) = get_parameters()
	inverse_cam_matrix = np.linalg.inv(np.reshape(np.array(camera_parameters['camera_matrix']['data']), (camera_parameters['camera_matrix']['rows'],camera_parameters['camera_matrix']['cols'])))
	cam_to_quad = np.linalg.inv(np.reshape(np.array(camera_parameters['rotation']),(3,3)))
	tcam = np.reshape(np.array(camera_parameters['translation']),(3,1))
	tracker = sort.Sort(max_age=max_age, min_hits=min_hits) #create instance of the SORT tracker
	cost_threshold = cost_threshold
	#Subscribe to image topic
	image_sub = rospy.Subscriber(camera_topic,Image,callback_image)
	#Subscribe to darknet_ros to get BoundingBoxes from YOLOv3
	sub_detection = rospy.Subscriber(detection_topic, BoundingBoxes , callback_det)
	#Publish results of object tracking
	pub_trackers = rospy.Publisher(tracker_topic, IntList, queue_size=10)
	#print(msg) #Testing msg that is published
	#pub_trackers.publish(msg)
	sub_odometry = rospy.Subscriber("Odometry",Odometry,callback_odom) 
	global pub_bbposes
	pub_bbposes = rospy.Publisher("BBposes",BBPoses,queue_size=10)
	rospy.spin()
Пример #2
0
def main():
    global tracker
    global msg
    msg = IntList()
    while not rospy.is_shutdown():
        #Initialize ROS node
        rospy.init_node('sort_tracker', anonymous=False)
        rate = rospy.Rate(10)
        # Get the parameters
        (camera_topic, detection_topic, tracker_topic, cost_threshold, max_age,
         min_hits) = get_parameters()
        tracker = sort.Sort(
            max_age=max_age,
            min_hits=min_hits)  #create instance of the SORT tracker
        cost_threshold = cost_threshold
        #Subscribe to image topic
        image_sub = rospy.Subscriber(camera_topic, Image, callback_image)
        #Subscribe to darknet_ros to get BoundingBoxes from YOLOv3
        sub_detection = rospy.Subscriber(detection_topic, BoundingBoxes,
                                         callback_det)
        #Publish results of object tracking
        pub_trackers = rospy.Publisher(tracker_topic, IntList, queue_size=10)
        #print(msg) #Testing msg that is published
        #pub_trackers.publish(msg)
        rate.sleep()
        rospy.spin()
Пример #3
0
def main():
    global tracker
    global encoder
    global msg
    msg = IntList()
    max_cosine_distance = 0.2
    nn_budget = 100
    metric = nn_matching.NearestNeighborDistanceMetric("cosine",
                                                       max_cosine_distance,
                                                       nn_budget)
    tracker = Tracker(metric)
    model_filename = "/home/joemasterjohn/deep_sort_ws/src/sort-deepsort-yolov3-ROS/sort_track/src/deep_sort/model_data/mars-small128.pb"  #Change it to your directory
    encoder = gdet.create_box_encoder(model_filename)
    #Initialize ROS node
    rospy.init_node('sort_tracker', anonymous=True)
    rate = rospy.Rate(100)
    # Get the parameters
    (camera_topic, detection_topic, tracker_topic) = get_parameters()
    #Subscribe to image topic
    image_sub = rospy.Subscriber(camera_topic, Image, callback_image)
    #Subscribe to darknet_ros to get BoundingBoxes from YOLOv3
    sub_detection = rospy.Subscriber(detection_topic, BoundingBoxes,
                                     callback_det)

    pub_trackers = rospy.Publisher(tracker_topic, IntList, queue_size=10)

    while not rospy.is_shutdown():
        #Publish results of object tracking
        #print(msg)
        pub_trackers.publish(msg)
        rate.sleep()
def main():
    global tracker
    global msg
    global detections
    global total_time
    global total_frames
    global start_time
    global cycle_time
    global tracker_id
    global iou_threshold
    global display
    global detection_event
    display = False
    total_frames = 0
    detection_event = False

    # holds tracker id
    counter = IntList()
    while not rospy.is_shutdown():
        #Initialize ROS node
        # frame +=1
        rospy.init_node('sort_tracker', anonymous=False)

        # Get the parameters
        (queue_size, camera_topic, detection_topic, tracker_topic,
         cost_threshold, iou_threshold, display, max_age, min_hits,
         fps) = get_parameters()
        cost_threshold = cost_threshold

        # loop twice per frame
        rate = rospy.Rate(3)

        tracker = sort.Sort(
            max_age=max_age,
            min_hits=min_hits)  #create instance of the SORT tracker

        #Subscribe to darknet_ros to get BoundingBoxes from yolov3-detections
        sub_detection = rospy.Subscriber(detection_topic, BoundingBoxes,
                                         callback_det)

        #Subscribe to image topic
        image_sub = rospy.Subscriber(camera_topic, Image, callback_image)

        #Publish results of object tracking
        # pub_trackers = rospy.Publisher(tracker_topic, IntList, queue_size=queue_size)
        # print(msg)
        # 1.5 = 2
        total_frames = math.ceil(total_frames + 1 / 2)
        #pub_trackers.publish(msg)
        rate.sleep()
        rospy.spin()