How Do I Improve the Recognition Speed?
The speed of the OCR API depends on the image size, which affects the time needed for network transmission and Base64 decoding. Therefore, you are advised to compress the images before using OCR to process them while ensuring the required level of resolution. This will accelerate image processing by the OCR API. The JPG image format is recommended.
Based on empirical data, it is recommended to keep small images (such as ID cards with sparse text) under 1 MB, and large images (such as dense documents of the A4 paper size) under 2 MB.
For details about how to compress an image, see the following code:
import cv2 def resize_image(image, max_size): """ This code is used to expand or downsize an image proportionally. It compares the long side of the image with the input parameter max_size. If the long side of the image exceeds max_size, the image is downsized proportionally. Otherwise, the original image is returned. :param max_size: maximum length of the long side of an image. (Set this parameter based on site requirements. You are advised to set this parameter to a value as small as possible as long as the resolution requirement is met.) :return: returns the downsized image or the original image. """ height, width = image.shape[:2] max_side = max(height, width) if max_side > max_size: scale = max_size / max_side image = cv2.resize(image, None, fx=scale, fy=scale) return image image = cv2.imread('test.png') image = resize_image(image, max_size=1024)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot