MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / _change_seg_tl

Method _change_seg_tl

leaderboard/team_code/base_agent.py:803–827  ·  view source on GitHub ↗

Adds 3 traffic light classes (green, yellow, red) to the segmentation image Args: seg_img ([type]): [description] depth_img ([type]): [description] traffic_lights ([type]): [description] _region_size (int, optional): [description]. Defaults to

(self, seg_img, depth_img, traffic_lights, _region_size=4)

Source from the content-addressed store, hash-verified

801 return matrix
802
803 def _change_seg_tl(self, seg_img, depth_img, traffic_lights, _region_size=4):
804 """Adds 3 traffic light classes (green, yellow, red) to the segmentation image
805
806 Args:
807 seg_img ([type]): [description]
808 depth_img ([type]): [description]
809 traffic_lights ([type]): [description]
810 _region_size (int, optional): [description]. Defaults to 4.
811 """
812 for tl in traffic_lights:
813 _dist = self._get_distance(tl.get_transform().location)
814
815 _region = np.abs(depth_img - _dist)
816
817 if tl.get_state() == carla.TrafficLightState.Red:
818 state = 23
819 elif tl.get_state() == carla.TrafficLightState.Yellow:
820 state = 24
821 elif tl.get_state() == carla.TrafficLightState.Green:
822 state = 25
823 else: #none of the states above, do not change class
824 state = 18
825
826 #seg_img[(_region >= _region_size)] = 0
827 seg_img[(_region < _region_size) & (seg_img == 18)] = state
828
829
830 def _get_dist(self, p1, p2):

Callers

nothing calls this directly

Calls 2

_get_distanceMethod · 0.95
get_transformMethod · 0.80

Tested by

no test coverage detected