コード例 #1
0
def test_calc_tfl_dist() -> None:
    pkl_path = 'dusseldorf_000049.pkl'
    prev_img_path = 'dusseldorf_000049_0000' + str(
        prev_frame_id) + '_leftImg8bit.png'
    curr_img_path = 'dusseldorf_000049_0000' + str(
        curr_frame_id) + '_leftImg8bit.png'
    prev_container = FrameContainer(prev_img_path)
    curr_container = FrameContainer(curr_img_path)
    with open(pkl_path, 'rb') as pkl_file:
        data = pickle.load(pkl_file, encoding='latin1')
    focal = data['flx']
    pp = data['principle_point']
    prev_container.traffic_light = np.array(data['points_' +
                                                 str(prev_frame_id)][0])
    curr_container.traffic_light = np.array(data['points_' +
                                                 str(curr_frame_id)][0])
    curr_container.EM = SFM.calc_EM(data, prev_frame_id, curr_frame_id)
    curr_container = SFM.calc_tfl_dist(prev_container, curr_container, focal,
                                       pp)
    visualize(prev_container, curr_container, focal, pp)
コード例 #2
0
    def run(self, frame, EM):
        self.curr_frame = FrameContainer(frame)
        self.curr_frame.EM = EM

        #part 1
        self.curr_frame.cordinates, self.curr_frame.cordinates_colors = find_tfl_lights(
            self.curr_frame.img)

        #part 2
        confirm_tfl_by_CNN(self.curr_frame, self.model)

        # part 3
        if self.prev_frame:
            SFM.calc_TFL_dist(self.prev_frame, self.curr_frame,
                              self.focal_length, self.principle_point)
コード例 #3
0
    def on_frame(self, frame):
        # step 1
        candidates, auxiliary_c = self.__get_lights(frame)

        # step 2
        traffic_lights, auxiliary_t = self.__get_tfl_lights(frame, candidates, auxiliary_c)

        # step 3
        curr_frame = FrameContainer(frame)
        curr_frame.traffic_light = traffic_lights
        distances = []

        if self.__prev_frame:
            curr_frame.EM = self.__egomotions['egomotion_' + str(self.__index - 1) + '-' + str(self.__index)]
            distances = self.__get_distance(curr_frame)

        self.__display(curr_frame, candidates, auxiliary_c, traffic_lights, auxiliary_t, distances)
        self.__prev_frame = curr_frame
        self.__index += 1

        return traffic_lights, auxiliary_t, distances
コード例 #4
0
    def on_frame(self, current_frame, frame_index):
        # phase 1
        candidates, auxliary = self.__get_candidates(current_frame)
        assert len(candidates) == len(auxliary)
        assert len(candidates) >= 0

        # phase 2
        traffic_lights, traffic_auxiliary = self.__get_tfl_coordinates(
            current_frame, candidates, auxliary)
        if len(traffic_lights) > len(candidates):
            traffic_lights = candidates
        assert len(traffic_lights) == len(traffic_auxiliary)
        assert len(traffic_lights) >= 0

        # phase 3
        current_frame = FrameContainer(current_frame)
        current_frame.traffic_light = traffic_lights

        if self.__prev_frame:
            try:
                current_frame.EM = self.__pkl_data['egomotion_' +
                                                   str(frame_index - 1) + '-' +
                                                   str(frame_index)]
            except KeyError:
                pass  # I have not yet decided how to handle this case

            distance = self.__get_dists(self.__prev_frame, current_frame,
                                        self.__prev_frame.traffic_light,
                                        traffic_lights)
            assert len(distance) == len(traffic_lights)
        else:
            distance = None

        self.__prev_frame = current_frame

        visualize(current_frame, candidates, auxliary, traffic_lights,
                  traffic_auxiliary, distance)

        return traffic_lights, traffic_auxiliary, distance
コード例 #5
0
    def run(self, curr_image_path: str, _id: int) -> Tuple[FrameContainer, List[int]]:

        if DEBUG is True:
            fig, (self.tfl_candidates, self.tfl, self.tfl_distance) = \
                plt.subplots(1, 3, figsize=(12, 5))

        self.curr_container = FrameContainer(curr_image_path)

        candidates, auxiliary = self.__get_tfl_candidates()
        assert len(candidates) == len(auxiliary)

        self.curr_container.traffic_light, tfl_aux = self.__get_tfl_coordinates(candidates, auxiliary)
        assert len(self.curr_container.traffic_light) == len(tfl_aux)
        assert len(self.curr_container.traffic_light) <= len(candidates)

        self.curr_container.traffic_lights_3d_location = self.__get_distance(_id)
        assert len(self.curr_container.traffic_lights_3d_location) == len(self.curr_container.traffic_light)

        if DEBUG is True:
            plt.show()

        self.__prev_container = self.curr_container

        return self.curr_container, tfl_aux
コード例 #6
0
 def run_product(self, image_path, frame_index):
     current_frame = FrameContainer(image_path)