def __init__(self, path): self.path = Path(path).resolve().absolute() self.cap = {} # VideoCapture objects self.size = {} # Frame sizes self.lastFrame = {} # Last frame sent to the device self.frames = {} # Frames read from the VideoCapture # Disparity shouldn't get streamed to the device, nothing to do with it. self.stream_types = ['color', 'left', 'right', 'depth'] file_types = ['color', 'left', 'right', 'disparity', 'depth'] extensions = ['mjpeg', 'avi', 'mp4', 'h265', 'h264'] for file in os.listdir(path): if not '.' in file: continue # Folder name, extension = file.split('.') if name in file_types and extension in extensions: self.cap[name] = cv2.VideoCapture(str(self.path / file)) if len(self.cap) == 0: raise RuntimeError( "There are no recordings in the folder specified.") # Load calibration data from the recording folder self.calibData = dai.CalibrationHandler(str(self.path / "calib.json")) # Read basic info about the straems (resolution of streams etc.) for name in self.cap: self.size[name] = self.get_size(self.cap[name]) self.color_size = None # By default crop image as needed to keep the aspect ratio self.keep_ar = True
import depthai as dai import argparse calibJsonFile = str( (Path(__file__).parent / Path('../models/depthai_calib.json')).resolve().absolute()) calibBackUpFile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute()) parser = argparse.ArgumentParser() parser.add_argument('calibJsonFile', nargs='?', help="Path to V6 calibration file in json", default=calibJsonFile) args = parser.parse_args() # Connect device with dai.Device() as device: deviceCalib = device.readCalibration() deviceCalib.eepromToJsonFile(calibBackUpFile) print("Calibration Data on the device is backed up at:") print(calibBackUpFile) calibData = dai.CalibrationHandler(args.calibJsonFile) status = device.flashCalibration(calibData) if status: print('Calibration Flash Successful') else: print('Calibration Flash Failed!!!')
Path('../models/depthai_v5.calib')).resolve().absolute()) calibBackUpFile = str((Path(__file__).parent / Path('depthai_calib_backup.json')).resolve().absolute()) parser = argparse.ArgumentParser() parser.add_argument('boardConfigFile', nargs='?', help="Path to board config file", default=boardConfigFile) parser.add_argument('calibBinaryFile', nargs='?', help="Path to version 5 .calib file", default=calibBinaryFile) args = parser.parse_args() # Connect device with dai.Device() as device: deviceCalib = device.readCalibration() deviceCalib.eepromToJsonFile(calibBackUpFile) print("Calibration Data on the device is backed up at:") print(calibBackUpFile) calibData = dai.CalibrationHandler(args.calibBinaryFile, args.boardConfigFile) status = device.flashCalibration(calibData) if status: print('Calibration Flash Successful') else: print('Calibration Flash Failed!!!')