69 lines
2.8 KiB
Python
69 lines
2.8 KiB
Python
import glob
|
||
import os.path as osp
|
||
import json
|
||
import os
|
||
|
||
def write_json(data, output_path):
|
||
with open(output_path, "w") as f:
|
||
json.dump(data, f, indent=None, separators=(',', ':'))
|
||
|
||
|
||
def read_json(input):
|
||
with open(input, "r") as f:
|
||
data = json.load(f)
|
||
return data
|
||
|
||
|
||
def read_img_paths(imgFolder):
|
||
imgPaths = []
|
||
for extension in ["jpg", "png", "jpeg", "bmp"]:
|
||
imgPaths += glob.glob(osp.join(imgFolder, "*.{}".format(extension)))
|
||
return imgPaths
|
||
|
||
|
||
def create_output_folder(baseFolder, outputFolder):
|
||
folder = osp.join(baseFolder, outputFolder)
|
||
if not osp.exists(folder):
|
||
os.makedirs(folder)
|
||
return folder
|
||
|
||
class DataPaths:
|
||
def __init__(self, base_dir):
|
||
self.base_path = base_dir
|
||
# intri路径
|
||
self.intri_base = osp.join(self.base_path, "intri")
|
||
# 内参图片路径,按照cam0, cam1, cam2, ...组织子文件夹
|
||
self.intri_chessboard_data = osp.join(self.intri_base, "chessboard_data")
|
||
# 内参标定中的棋盘格角点检测可视化, 按照cam0, cam1, cam2, ...组织子文件夹
|
||
self.intri_chessboard_vis = osp.join(self.intri_base, "chessboard_vis")
|
||
# 需要畸变校正的图片路径,文件夹下存放cam0.jpg, cam1.jpg, cam2.jpg, ...只有图片
|
||
self.intri_undistort_data = osp.join(self.intri_base, "undistort_data")
|
||
self.intri_undistort_result = osp.join(self.intri_base, "undistort_result")
|
||
|
||
# extri路径
|
||
self.extri_base = osp.join(self.base_path, "extri")
|
||
# 外参标定使用的棋盘格图片路径,文件夹下存放cam0.jpg, cam1.jpg, cam2.jpg, ...一个相机一个图片
|
||
self.extri_chessboard_data = osp.join(self.extri_base,"extri_data")
|
||
# 绘制外参标定中的棋盘格角点检测可视化(原点和终点), 按照cam0, cam1, cam2, ...组织子文件夹
|
||
self.extri_chessboard_vis = osp.join(self.extri_base, "extri_vis")
|
||
|
||
# check需要的路径
|
||
self.check_base = osp.join(self.base_path, "check")
|
||
# check使用的棋盘格图片路径,文件夹下存放cam0.jpg, cam1.jpg, cam2.jpg, ...
|
||
# 一个相机一张图片,主要是用于角点提取函数
|
||
self.check_data = osp.join(self.check_base, "check_data")
|
||
# 绘制外参标定中的棋盘格角点检测可视化(原点和终点), 按照cam0, cam1, cam2, ...组织子文件夹
|
||
self.check_vis = osp.join(self.check_base, "extri_vis")
|
||
|
||
# json输出路径
|
||
self.json_out_base = osp.join(self.base_path, 'json_out')
|
||
self.intri_json_path = osp.join(self.json_out_base, 'intri.json')
|
||
self.extri_json_path = osp.join(self.json_out_base, 'extri.json')
|
||
|
||
|
||
def print_paths(self):
|
||
print("to be implemented")
|
||
|
||
|
||
base_dir = "data"
|
||
DataPath = DataPaths(base_dir) |