TeddyYao commited on
Commit
8129ecd
·
verified ·
1 Parent(s): 9b00caf

Create ocr_test.py

Browse files
Files changed (1) hide show
  1. ocr_test.py +14 -0
ocr_test.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytesseract
2
+ from PIL import Image
3
+
4
+ # 创建一张测试图像
5
+ from PIL import ImageDraw
6
+
7
+ img = Image.new('RGB', (300, 100), color = (255, 255, 255))
8
+ d = ImageDraw.Draw(img)
9
+ d.text((10, 10), "Hello LinkedIn OCR Test", fill=(0, 0, 0))
10
+ img.save("test_image.png")
11
+
12
+ # 尝试用 tesseract 识别
13
+ text = pytesseract.image_to_string(Image.open("test_image.png"))
14
+ print("识别结果:", text)