def run(self, rebuild): ''' DOCSTRING: given bool representing whether or not to rebuild training data sets runs HR initialization code and main loop code ''' r = rospy.Rate(10) time.sleep(2) # If new training data, set rebuild to True to rebuild SVMs if rebuild == True: self.process_data_svm() self.SVM = self.train_svm('svm_data') self.SVM_alpha = self.train_svm('svm_alphadata') self.SVM_num = self.train_svm('svm_numdata') while not rospy.is_shutdown(): # MAIN LOOP if self.is_running: e1 = cv2.getTickCount() self.update_frame() # out_image = Process.get_paper_region(self.frame) self.chars = Process.get_text_roi(self.frame) self.process_digits(self.chars, detect_words=True) #self.find_words(self.chars) self.output_image() e2 = cv2.getTickCount() # print (e2-e1)/cv2.getTickFrequency() r.sleep() cv2.destroyAllWindows()
def get_image_text(self, frame): self.chars = Process.get_text_roi(frame,show_window=False) self.chars = self.process_digits(self.chars) if self.chars: self.chars.sort(key = lambda roi: roi.x) word = ''.join([chr(item.result) for item in self.chars]) return word
def run(self): r = rospy.Rate(10) time.sleep(2) while not rospy.is_shutdown(): self.update_frame() self.numbers = Process.get_text_roi(self.frame) self.output_image() r.sleep()
def get_image_text(self, frame): ''' DESC: Get the words out of an image ARGS: self - object - current HR object frame - image - current image to analyze RETURNS: string representing text found in frame ''' self.chars = Process.get_text_roi(frame, show_window=False) self.chars = self.process_digits(self.chars) # If chars exists, if self.chars: word = get_publish_text(chars) return word
def run(self): r = rospy.Rate(10) time.sleep(2) self.process_data_svm() self.train_svm() self.test_ocr() # print accuracy of current OCR while not rospy.is_shutdown(): e1 = cv2.getTickCount() self.update_frame() # out_image = Process.get_paper_region(self.frame) self.chars = Process.get_text_roi(self.frame) self.process_digits(self.chars,detect_words=True) #self.find_words(self.chars) self.output_image() e2 = cv2.getTickCount() # print (e2-e1)/cv2.getTickFrequency() r.sleep()