Here are the codes at the end of the calibrate.py
resImage = None
if not self.device.isClosed():
dev_info = self.device.getDeviceInfo()
mx_serial_id = dev_info.getMxId()
calib_dest_path = dest_path + '/' + mx_serial_id + '.json'
calibration_handler.eepromToJsonFile(calib_dest_path)
is_write_succesful = False
try:
is_write_succesful = self.device.flashCalibration(
calibration_handler)
except:
print("Writing in except...")
is_write_succesful = self.device.flashCalibration(
calibration_handler)
if is_write_succesful:
resImage = create_blank(900, 512, rgb_color=green)
text = "Calibration Succesful with"
cv2.putText(resImage, text, (10, 250),
font, 2, (0, 0, 0), 2)
text = "Epipolar error of " + str(epiploar_error)
cv2.putText(resImage, text, (10, 300),
font, 2, (0, 0, 0), 2)
else:
resImage = create_blank(900, 512, rgb_color=red)
text = "EEprom Write Failed!! " + str(epiploar_error)
cv2.putText(resImage, text, (10, 250),
font, 2, (0, 0, 0), 2)
text = "Try recalibrating !!"
cv2.putText(resImage, text, (10, 300),
font, 2, (0, 0, 0), 2)
else:
calib_dest_path = dest_path + '/depthai_calib.json'
# calibration_handler.eepromToJsonFile(calib_dest_path)
resImage = create_blank(900, 512, rgb_color=red)
text = "Calibratin succesful. " + str(epiploar_error)
cv2.putText(resImage, text, (10, 250), font, 2, (0, 0, 0), 2)
# text = "Device not found to write to EEPROM"
# cv2.putText(resImage, text, (10, 300), font, 2, (0, 0, 0), 2)
if resImage is not None:
cv2.imshow("Result Image", resImage)
cv2.waitKey(0)
except AssertionError as e:
print("[ERROR] " + str(e))
raise SystemExit(1)
def run(self):
if 'capture' in self.args.mode:
try:
if Path('dataset').exists():
shutil.rmtree('dataset/')
Path("dataset/left").mkdir(parents=True, exist_ok=True)
Path("dataset/right").mkdir(parents=True, exist_ok=True)
if not self.args.disableRgb:
Path("dataset/rgb").mkdir(parents=True, exist_ok=True)
except OSError:
traceback.print_exc()
print("An error occurred trying to create image dataset directories!")
raise SystemExit(1)
self.show_info_frame()
self.capture_images()
self.dataset_path = str(Path("dataset").absolute())
if 'process' in self.args.mode:
self.calibrate()
print('py: DONE.')
if name == "main":
Main().run()