Currently I am working on the Vietnamese text detection from the image
So, to detect the text in Image I am using the PaddleOcr Detection because I need line to line detection. Paddleocr is showing 100% result for that, we can do recognition using PaddleOcr has PaddleOcr didn't trained on Vietnamese it's not giving 100% results.
So, for recognition I am going with vietocr and its showing 100% results but the problem with vietocr is that it is only working when we pass cropped image not on full images.
My plan to crop the Image into multiple by using Bounding box co-ordinates generated from PaddleOcr
I am using PaddleOcr for the text detection
Sample Code
from paddleocr import PaddleOCR,draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `french`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True) # need to run only once to download and load model into memory
img_path = '/content/im1502.jpg'
result = ocr.ocr(img_path, cls=True)
resultss = result
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
# draw result
from PIL import Image
result = result[0]
results = result
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts=None, scores=None, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
Bounding Box Image and Results
[[[108.0, 78.0], [289.0, 93.0], [286.0, 131.0], [104.0, 116.0]],
[[51.0, 230.0], [267.0, 235.0], [266.0, 272.0], [50.0, 267.0]],
[[17.0, 304.0], [343.0, 304.0], [343.0, 340.0], [17.0, 340.0]]]
Recognition with VietOcr
import matplotlib.pyplot as plt
from PIL import Image
from vietocr.tool.predictor import Predictor
from vietocr.tool.config import Cfg
config = Cfg.load_config_from_name('vgg_transformer')
# config['weights'] = './weights/transformerocr.pth'
#config['weights'] = 'https://drive.google.com/uc?id=13327Y1tz1ohsm5YZMyXVMPIOjoOA0OaA'
config['cnn']['pretrained']=False
#config['device'] = 'cuda:0'
config['predictor']['beamsearch']=False
detector = Predictor(config)
img = '/content/im1502.jpg'
img = Image.open(img)
plt.imshow(img)
result = detector.predict(img)
result
The result is
SẢNH CHUNG
So can anyone help me with how to crop the image using paddleocr bounding box coordinates