def __init__(self, name, isLeftCamera, targetImagerLeft, targetImagerRight): IDEFProcess.__init__(self, name) self.cameraCode = 'L' if isLeftCamera else 'R' self.targetImagerLeft = targetImagerLeft self.targetImagerRight = targetImagerRight self.live_image_transfer = False
def initialze(): ImageGene.GeneDictionary = IDEFProcess.extract_training_dictionary() ImageGene.StereoPairs = IDEFProcess.extract_training_stereo_pairs( ImageGene.GeneDictionary) ImageGene.GeneColors = {} max = 0 min = 9999 for k in ImageGene.StereoPairs: lib = ImageGene.analyze_image_blur(ImageGene.imagefile(k, True)) rib = ImageGene.analyze_image_blur(ImageGene.imagefile(k, False)) v = (lib + rib) / 2.0 if v > max: max = v elif v < min: min = v ImageGene.GeneColors[k] = v ctr = 0 for k, v in ImageGene.GeneColors.items(): c1 = int(ctr / 26) c2 = int(ctr % 26) ctr += 1 c1 = chr(ord('a') + c1) c2 = chr(ord('a') + c2) v = ImageGene.GeneColors[k] vn = (v - min) / (max - min) v1 = [int(vn * 255), 0, 0, c1 + c2] ImageGene.GeneColors[k] = v1
def capture_chessboards(self): leftimager = HAL.Controller.Controllers[0].imagers[0] rightimager = HAL.Controller.Controllers[0].imagers[1] icp = ChessboardCaptureProcess("ChessCap", leftimager, rightimager) icp.initialize({}) icp.status_message = self.change_status_message IDEFProcess.add_process(icp)
def process_stereo_set(self): icp = StereoIntrinsicsCalculatorProcess( "ProcSter", HAL.Controller.Controllers[0].imagers[0], HAL.Controller.Controllers[0].imagers[1]) icp.initialize({"RECORDING": False}) icp.status_message = self.change_status_message IDEFProcess.add_process(icp)
def __init__(self): self.left_image_display = None self.right_image_display = None self.training_dictionary = IDEFProcess.extract_training_dictionary() self.stereo_pairs = IDEFProcess.extract_training_stereo_pairs( self.training_dictionary) self.stereo_pair_index = 0 self.blurValue = None self.top = tk.Toplevel() self.top.title("Image Inspector") canvas_frame = tk.Frame(self.top) self.left_image_display = self.create_image_display(canvas_frame) self.right_image_display = self.create_image_display(canvas_frame) canvas_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES) data_frame = tk.Frame(self.top) tk.Button(data_frame, width=10, text="Previous", command=self.previous_image).pack(side=tk.LEFT) self.leftBlurValue = tk.Label(data_frame, text="0.000000") self.leftBlurValue.pack(side=tk.LEFT) self.rightBlurValue = tk.Label(data_frame, text="0.000000") self.rightBlurValue.pack(side=tk.LEFT) tk.Button(data_frame, width=10, text="Delete Pair", command=self.delete_pair).pack(side=tk.LEFT) tk.Button(data_frame, width=10, text="Next", command=self.next_image).pack(side=tk.LEFT) tk.Button(data_frame, width=10, text="Report", command=self.report).pack(side=tk.LEFT) tk.Button(data_frame, width=10, text="Weed", command=self.weed_images).pack(side=tk.LEFT) data_frame.pack(side=tk.TOP)
def on_completion(self): if Notifier.activeNotifier is not None: Notifier.activeNotifier.speak_message("completed") ds = self.stages['DistortionCalculatorStage'] intrinsics = ds.output_containers[ 'CAMERAINTRINSICS'].value # type: ScalarContainer reperr = ds.output_containers[ 'REPROJECTIONERROR'] # type: ScalarContainer self.status_message("Reprojection error is {}".format(reperr.value)) translated = {} for n, v in intrinsics.items(): if isinstance(v, numpy.ndarray): translated[n] = IDEFProcess.serialize_matrix_to_json(v) else: translated[n] = v translated['TIMESTAMP'] = datetime.datetime.now().isoformat() translated['ID'] = uuid.uuid4().hex imager = self.locals['IMAGER'].value translated['CONTROLLER'] = imager.controller.resource translated['CAMERAINDEX'] = imager.imager_address translated['MATCHCOUNT'] = self.locals['MATCHCOUNT'].value translated['MATCHSEPARATION'] = self.locals['MATCHSEPARATION'].value cfg = json.dumps(translated, ensure_ascii=False) sc = self.get_container('IMAGER').value sc.controller.publish_message(sc.imager_address, "intrinsics", cfg) filename = sc.calibration_filename() file = open(filename, "w") file.write(cfg) file.close() filename = "../CalibrationRecords/IntrinsicsHistory.txt" if os.path.isfile(filename): file = open(filename, "a") file.write(",\n") else: file = open(filename, "w") file.write(cfg) file.close()
def __init__(self, parent, *args, **kwargs): super(MasterControl, self).__init__(parent) MasterControl.application_singleton = self tk.Frame.__init__(self, parent, *args, **kwargs) self.pack(fill=tk.BOTH, expand=tk.YES, side=tk.LEFT) self.parent = parent # start the notification service - note this is platform specific! MacNotifier() self.left_imager = None self.right_imager = None self.common_data = None self.programbuttons = None self.trigger = False self.stereo_alpha_var = tk.StringVar() self.stereo_scale_var = tk.StringVar() self.stereo_alpha_var.set('-1') self.stereo_alpha_var.trace('w', self.update_stereo_alpha) self.stereo_scale_var.set('1') self.stereo_scale_var.trace('w', self.update_stereo_scale) self.stereobm_config = {"enabled": 0} self.calibrationdata = None image = ImageTk.PhotoImage(Image.open("../resources/console.jpg")) ctl = tk.Label(self, image=image) ctl.image = image ctl.place(x=0, y=0, relwidth=1, relheight=1) self.after(2000, self.open_display) HAL.Controller.initialize_controllers(self) IDEFProcess.bind_imager_input_functions( HAL.Controller.Controllers[0].get_left_imager()) IDEFProcess.bind_imager_input_functions( HAL.Controller.Controllers[0].get_right_imager()) IDEFProcess.initialize_image_intake(['cancer']) self.process_thread = threading.Thread( target=IDEFProcess.process_dispatcher) self.process_thread.daemon = True self.process_thread.start()
def imagefile(self, key, isLeft): fnd = "L" if isLeft else "R" return IDEFProcess.stereo_session_image_folder( ) + "/" + key + "_unknownctlr_" + fnd + ".jpg"
def __init__(self, name, targetImagerLeft, targetImagerRight): IDEFProcess.__init__(self, name) self.targetImagerLeft = targetImagerLeft self.targetImagerRight = targetImagerRight
def __init__(self, name, targetImager): IDEFProcess.__init__(self, name) self.targetImager = targetImager