def init (): global lbControl, camera, calibrator, config, lbVersion # read config config = ConfigReader(CONFIG_FILE) lbVersion = int(config.get("MAIN","version")) try: #init vars if lbVersion == 0: from hardware.letterboxControlTest import LetterboxControlTest lbControl = LetterboxControlTest() elif lbVersion == 1: from hardware.letterboxControlV1 import LetterboxControlV1 lbControl = LetterboxControlV1() else: from hardware.letterboxControlV2 import LetterboxControlV2 lbControl = LetterboxControlV2() # start camera if lbVersion == 0: from camera.cameraControlTest import CameraControlTest camera = CameraControlTest() else: from camera.cameraControl import CameraControl camera = CameraControl() calibrator = CameraCalibrator(CAMERA_MATRIX_FILE) # init hardware lbControl.calibrate() logger.info(" # initializing...") except Exception as err: logger.error(err) lbControl.flashFeedbackLed(10) stop() return False lbControl.flashFeedbackLed(2); logger.info("# finished initializing. starting loop...") return True
def init (initCamera=True, cleanup=True): global lbControl, camera, config, lbVersion # read config config = ConfigReader(CONFIG_FILE) lbVersion = int(config.get("MAIN","version")) try: #init vars if lbVersion == 0: from hardware.letterboxControlTest import LetterboxControlTest lbControl = LetterboxControlTest(cleanup=cleanup) elif lbVersion == 1: from hardware.letterboxControlV1 import LetterboxControlV1 lbControl = LetterboxControlV1(cleanup=cleanup) else: from hardware.letterboxControlV2 import LetterboxControlV2 lbControl = LetterboxControlV2(cleanup=cleanup) # start camera if initCamera: if lbVersion == 0: from camera.cameraControlTest import CameraControlTest camera = CameraControlTest() else: from camera.cameraControl import CameraControl camera = CameraControl() except Exception as err: print(err) lbControl.flashFeedbackLed(10) stop() return False lbControl.flashFeedbackLed(2); print("# finished initializing") return True