import cv2 import numpy as np from paddleocr import PaddleOCR import traceback def test(): try: print("Loading model...") ocr = PaddleOCR(use_angle_cls=True, lang='en') print("Model loaded.") # Create a dummy image print("Creating dummy image...") img = np.zeros((400, 600, 3), dtype=np.uint8) cv2.putText(img, "NIK : 1234567890123456", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2) # Preprocess gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8)) enhanced_img = clahe.apply(gray) enhanced_bgr = cv2.cvtColor(enhanced_img, cv2.COLOR_GRAY2BGR) print("Running OCR...") ocr_results = ocr.ocr(enhanced_bgr, cls=True) print("OCR successful:", ocr_results) except Exception as e: print("ERROR:") traceback.print_exc() if __name__ == "__main__": test()