Don't upload pictures
Image content is: 3333333 422140 4854454 5298811 (format looks something like this, there are obvious among space)
Here are the results:
{' log_id: 6857144026374688915, 'words_result_num: 3,' words_result: [{' words', '3333333'}, {' words', '422140'}, {' words', '48544545298811'}]}
3333333
422140
48544545298811
Question is: recognition results and pictures do not correspond, clearly there are 4 Numbers, can only show the three groups, the last two sets of automatic "combination" together,
Is a great god, code or baidu OCR problems?
If the code, please help to optimize, thank you,
On code:
Import the rid_device_info_keyboard # for mouse and keyboard input
The from PIL import ImageGrab # is used for image was obtained from the clipboard and save
The from aip import AipOcr # to recognize text contained in images and output
Import pyperclip # is used to identify your text to the clipboard in convenient paste directly
If __name__=="__main__ ':
Press CTRL + c # before performing the following statement
The rid_device_info_keyboard. Wait (hotkey='CTRL + c)
CTRL + c # save screenshots to the clipboard, ImageGrab read image from the clipboard
Img1=ImageGrab. Grabclipboard ()
# print (type (img))
# file name
Img_path='1. PNG'
Save the file #
Img1. Save (img_path)
# baidu API to perform the required data, run into your APP_ID, API_KEY and SECRET_KEY
APP_ID='* * * * * * * * * *'
API_KEY='* * * * * * *
SECRET_KEY='* * * * * * * * * * * * * * * * *'
# initialization AipOcr
AipOcr=aipOcr (APP_ID, API_KEY and SECRET_KEY)
With the open (img_path, 'rb') as f:
Img2=f.r ead ()
# print (type (img2))
# recognition image and returns the results
Result=aipOcr. BasicAccurate (img2)
Print (result)
datahttps://bbs.csdn.net/topics/='
For r the result in [' words_result] :
Data=https://bbs.csdn.net/topics/data + r/' words' + '\ n'
Print (data)
# the text copied to the clipboard
Pyperclip. Copy (data)