parameters: (self, img, det=True, rec=True, cls=True)
docstring: ocr with paddleocr
          args：
              img: img for ocr, support ndarray, img_path and list or ndarray
              det: use text detection or not, if false, only rec will be exec. default is True
              rec: use text recognition or not, if false, only det will be exec. default is True
docstring_summary: ocr with paddleocr
          args：
              img: img for ocr, support ndarray, img_path and list or ndarray
              det: use text detection or not, if false, only rec will be exec. default is True
              rec: use text recognition or not, if false, only det will be exec. default is True
docstring_tokens: ocr with paddleocr args： img : img for ocr support ndarray img_path and list or ndarray det : use text detection or not if false only rec will be exec . default is True rec : use text recognition or not if false only det will be exec . default is True
function: def ocr(self, img, det=True, rec=True, cls=True):
          """
          ocr with paddleocr
          args：
              img: img for ocr, support ndarray, img_path and list or ndarray
              det: use text detection or not, if false, only rec will be exec. default is True
              rec: use text recognition or not, if false, only det will be exec. default is True
          """
          assert isinstance(img, (np.ndarray, list, str))
          if isinstance(img, list) and det == True:
              logger.error('When input a list of images, det must be false')
              exit(0)
          if cls == True and self.use_angle_cls == False:
              logger.warning(
                  'Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process'
              )
  
          if isinstance(img, str):
              # download net image
              if img.startswith('http'):
                  download_with_progressbar(img, 'tmp.jpg')
                  img = 'tmp.jpg'
              image_file = img
              img, flag = check_and_read_gif(image_file)
              if not flag:
                  with open(image_file, 'rb') as f:
                      np_arr = np.frombuffer(f.read(), dtype=np.uint8)
                      img = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
              if img is None:
                  logger.error("error in loading image:{}".format(image_file))
                  return None
          if isinstance(img, np.ndarray) and len(img.shape) == 2:
              img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
          if det and rec:
              dt_boxes, rec_res = self.__call__(img, cls)
              return [[box.tolist(), res] for box, res in zip(dt_boxes, rec_res)]
          elif det and not rec:
              dt_boxes, elapse = self.text_detector(img)
              if dt_boxes is None:
                  return None
              return [box.tolist() for box in dt_boxes]
          else:
              if not isinstance(img, list):
                  img = [img]
              if self.use_angle_cls and cls:
                  img, cls_res, elapse = self.text_classifier(img)
                  if not rec:
                      return cls_res
              rec_res, elapse = self.text_recognizer(img)
              return rec_res
function_tokens: def ocr ( self , img , det = True , rec = True , cls = True ) : assert isinstance ( img , ( np . ndarray , list , str ) ) if isinstance ( img , list ) and det == True : logger . error ( 'When input a list of images, det must be false' ) exit ( 0 ) if cls == True and self . use_angle_cls == False : logger . warning ( 'Since the angle classifier is not initialized, the angle classifier will not be uesd during the forward process' ) if isinstance ( img , str ) : # download net image if img . startswith ( 'http' ) : download_with_progressbar ( img , 'tmp.jpg' ) img = 'tmp.jpg' image_file = img img , flag = check_and_read_gif ( image_file ) if not flag : with open ( image_file , 'rb' ) as f : np_arr = np . frombuffer ( f . read ( ) , dtype = np . uint8 ) img = cv2 . imdecode ( np_arr , cv2 . IMREAD_COLOR ) if img is None : logger . error ( "error in loading image:{}" . format ( image_file ) ) return None if isinstance ( img , np . ndarray ) and len ( img . shape ) == 2 : img = cv2 . cvtColor ( img , cv2 . COLOR_GRAY2BGR ) if det and rec : dt_boxes , rec_res = self . __call__ ( img , cls ) return [ [ box . tolist ( ) , res ] for box , res in zip ( dt_boxes , rec_res ) ] elif det and not rec : dt_boxes , elapse = self . text_detector ( img ) if dt_boxes is None : return None return [ box . tolist ( ) for box in dt_boxes ] else : if not isinstance ( img , list ) : img = [ img ] if self . use_angle_cls and cls : img , cls_res , elapse = self . text_classifier ( img ) if not rec : return cls_res rec_res , elapse = self . text_recognizer ( img ) return rec_res