def extract_text(self): temp_path = 'text_temp.png' cv2.imwrite(temp_path, self.image) self.text = pytesseract.image_to_string(Image.open(temp_path), lang=self.lang) os.remove(temp_path) return self.text