ros/src/tl_detector/tl_detector.py
def image_cb(self, msg):
        """Identifies red lights in the incoming camera image and publishes the index
            of the waypoint closest to the red light's stop line to /traffic_waypoint

        Args:
            msg (Image): image from car-mounted camera

        """
        self.has_image = True
        self.camera_image = msg

        # save some image to disk, switch on the automatic mode to activate the saving
#        if self.dbw_enabled:
#            # create the directory to save to if not already create
#            if not os.path.exists(SIMULATOR_DIR):
#                os.makedirs(SIMULATOR_DIR)
#
#            cv_image = self.bridge.imgmsg_to_cv2(self.camera_image, "bgr8")
#            filename = os.path.join(SIMULATOR_DIR, "{}.png".format(str(uuid.uuid4())))
#            cv2.imwrite(filename, cv_image)

        light_wp, state = self.process_traffic_lights()

        '''
        Publish upcoming red lights at camera frequency.
        Each predicted state has to occur `STATE_COUNT_THRESHOLD` number
        of times till we start using it. Otherwise the previous stable state is
        used.
        '''
        if self.state != state:
            self.state_count = 0
            self.state = state
        elif self.state_count >= STATE_COUNT_THRESHOLD:
            self.last_state = self.state
            light_wp = light_wp if state == TrafficLight.RED else -1
            self.last_wp = light_wp
            self.upcoming_red_light_pub.publish(Int32(light_wp))
        else:
            self.upcoming_red_light_pub.publish(Int32(self.last_wp))
        self.state_count += 1
Identifies red lights in the incoming camera image and publishes the index
            of the waypoint closest to the red light's stop line to /traffic_waypoint

        Args:
            msg (Image): image from car-mounted camera

        
Identifies red lights in the incoming camera image and publishes the index
of the waypoint closest to the red light's stop line to /traffic_waypoint
Identifies red lights in the incoming camera image and publishes the index of the waypoint closest to the red light ' s stop line to / traffic_waypoint
def image_cb(self, msg):
        self.has_image = True
        self.camera_image = msg
            cv_image = self.bridge.imgmsg_to_cv2(self.camera_image, "bgr8")
            filename = os.path.join(SIMULATOR_DIR, "{}.png".format(str(uuid.uuid4())))
            cv2.imwrite(filename, cv_image)
        light_wp, state = self.process_traffic_lights()
        if self.state != state:
            self.state_count = 0
            self.state = state
        elif self.state_count >= STATE_COUNT_THRESHOLD:
            self.last_state = self.state
            light_wp = light_wp if state == TrafficLight.RED else -1
            self.last_wp = light_wp
            self.upcoming_red_light_pub.publish(Int32(light_wp))
        else:
            self.upcoming_red_light_pub.publish(Int32(self.last_wp))
        self.state_count += 1
def image_cb ( self , msg ) : self . has_image = True self . camera_image = msg light_wp , state = self . process_traffic_lights ( ) '''
        Publish upcoming red lights at camera frequency.
        Each predicted state has to occur `STATE_COUNT_THRESHOLD` number
        of times till we start using it. Otherwise the previous stable state is
        used.
        ''' if self . state != state : self . state_count = 0 self . state = state elif self . state_count >= STATE_COUNT_THRESHOLD : self . last_state = self . state light_wp = light_wp if state == TrafficLight . RED else - 1 self . last_wp = light_wp self . upcoming_red_light_pub . publish ( Int32 ( light_wp ) ) else : self . upcoming_red_light_pub . publish ( Int32 ( self . last_wp ) ) self . state_count += 1
Identifies red lights in the incoming camera image and publishes the index
of the waypoint closest to the red light's stop line to /traffic_waypoint
Identifies red lights in the incoming camera image and publishes the index of the waypoint closest to the red light ' s stop line to / traffic_waypoint
"""Identifies red lights in the incoming camera image and publishes the index
            of the waypoint closest to the red light's stop line to /traffic_waypoint

        Args:
            msg (Image): image from car-mounted camera

        """ # save some image to disk, switch on the automatic mode to activate the saving #        if self.dbw_enabled: #            # create the directory to save to if not already create #            if not os.path.exists(SIMULATOR_DIR): #                os.makedirs(SIMULATOR_DIR) # #            cv_image = self.bridge.imgmsg_to_cv2(self.camera_image, "bgr8") #            filename = os.path.join(SIMULATOR_DIR, "{}.png".format(str(uuid.uuid4()))) #            cv2.imwrite(filename, cv_image) '''
        Publish upcoming red lights at camera frequency.
        Each predicted state has to occur `STATE_COUNT_THRESHOLD` number
        of times till we start using it. Otherwise the previous stable state is
        used.
        '''
self
msg
image from car-mounted camera
image from car - mounted camera