camera_calibrate/calib_tools.py

31 lines
729 B
Python
Raw Normal View History

import os
import numpy as np
import cv2 as cv
import glob
import os.path as osp
import json
from tqdm import tqdm
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