예제 #1
0
    def _load_image_file_names(self):
        """Load image files names

        Note: this function only obtains the image file names, it does not load
        images to memory

        Parameters
        ----------
        sequence_data_path : str
            Path to where VO sequence data is

        """
        data_path = join(self.base_dir, self.date, self.drive_dir)

        self.image_00_files = walkdir(join(data_path, "image_00"), ".png")
        self.image_00_files.sort(
            key=lambda f: int("".join(filter(str.isdigit, f))))

        self.image_01_files = walkdir(join(data_path, "image_01"), ".png")
        self.image_01_files.sort(
            key=lambda f: int("".join(filter(str.isdigit, f))))

        self.image_02_files = walkdir(join(data_path, "image_02"), ".png")
        self.image_02_files.sort(
            key=lambda f: int("".join(filter(str.isdigit, f))))

        self.image_03_files = walkdir(join(data_path, "image_03"), ".png")
        self.image_03_files.sort(
            key=lambda f: int("".join(filter(str.isdigit, f))))
예제 #2
0
    def preprocess_images(self):
        """ Preprocess images """
        image_files = walkdir(self.images_dir)
        nb_images = len(image_files)

        # Loop through calibration images
        for i in range(nb_images):
            # Load images and find chessboard corners
            image = cv2.imread(image_files[i])
            corners = self.chessboard.find_corners(image)
            self.images.append(image)

            # Calculate camera to chessboard transform
            K = self.intrinsics.K()
            P_c = self.chessboard.calc_corner_positions(corners, K)
            nb_corners = corners.shape[0]
            self.corners2d.append(corners.reshape((nb_corners, 2)))
            self.corners3d.append(P_c)

            # Undistort corners in camera 0
            corners_ud = self.intrinsics.undistort_points(corners)
            image_ud, K_new = self.intrinsics.undistort_image(image)
            pixels_ud = self.ideal2pixel(corners_ud, K_new)
            self.images_ud.append(image_ud)

            # Calculate camera to chessboard transform
            K_new = self.intrinsics.K_new
            P_c = self.chessboard.calc_corner_positions(pixels_ud, K_new)
            self.corners2d_ud.append(pixels_ud)
            self.corners3d_ud.append(P_c)

        self.corners2d = np.array(self.corners2d)
        self.corners3d = np.array(self.corners3d)
        self.corners2d_ud = np.array(self.corners2d_ud)
        self.corners3d_ud = np.array(self.corners3d_ud)
예제 #3
0
    def _load_image_file_names(self, sequence_data_path):
        """Load image files names

        Note: this function only obtains the image file names, it does not load
        images to memory

        Parameters
        ----------
        sequence_data_path : str
            Path to where VO sequence data is

        """
        image_0_path = join(sequence_data_path, "image_0")
        image_1_path = join(sequence_data_path, "image_1")

        self.image_0_files = walkdir(image_0_path, ".png")
        self.image_1_files = walkdir(image_1_path, ".png")

        self.image_0_files.sort(
            key=lambda f: int("".join(filter(str.isdigit, f))))
        self.image_1_files.sort(
            key=lambda f: int("".join(filter(str.isdigit, f))))
예제 #4
0
    def _load_oxts_data(self):
        """Load Oxts data"""
        path = join(self.base_dir, self.date, self.drive_dir, "oxts", "data")
        oxts_files = walkdir(path, ".txt")
        oxts_files.sort(key=lambda f: int("".join(filter(str.isdigit, f))))

        # Load oxts data
        for i in range(len(oxts_files)):
            # Open and load text file
            oxts_file = open(oxts_files[i], "r")
            data = oxts_file.readlines()
            oxts_file.close()

            # Split Oxts data
            data = " ".join(data)
            data = data.split(" ")
            data = [float(x) for x in data]

            data = {
                "lat": data[0],
                "lon": data[1],
                "alt": data[2],
                "roll": data[3],
                "pitch": data[4],
                "yaw": data[5],
                "vn": data[6],
                "ve": data[7],
                "vf": data[8],
                "vl": data[9],
                "vu": data[10],
                "ax": data[11],
                "ay": data[12],
                "az": data[13],
                "af": data[14],
                "al": data[15],
                "au": data[16],
                "wx": data[17],
                "wy": data[18],
                "wz": data[19],
                "wf": data[20],
                "wl": data[21],
                "wu": data[22],
                "pos_accuracy": data[23],
                "vel_accuracy": data[24],
                "navstat": data[25],
                "numsats": data[26],
                "posmode": data[27],
                "velmode": data[28],
                "orimode": data[29]
            }
            self.oxts.append(data)
예제 #5
0
    def load_preprocessed(self):
        files = walkdir(self.data_path)
        files.sort(key=lambda f: int(os.path.splitext(os.path.basename(f))[0]))
        if len(files) == 0:
            err_msg = "No data files found in [%s]!" % (self.data_path)
            raise RuntimeError(err_msg)

        for f in files:
            data = self.load_preprocessed_file(f)
            self.target_points.append(data["target_points"])
            self.corners2d.append(data["corners2d"])
            self.corners3d.append(data["corners3d"])

        self.target_points = np.array(self.target_points)
        self.corners2d = np.array(self.corners2d)
        self.corners3d = np.array(self.corners3d)
        self.corners2d_ud = self.corners2d
        self.corners3d_ud = self.corners3d