Skip to content
Snippets Groups Projects
Commit 0d228b85 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

Add hust_code OCR

parent 30e6c197
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,13 @@ Just modify config.py and enjoy!
## requirements
```bash
sudo pacman -S python-selenium geckodriver
sudo pacman -S python-selenium geckodriver python-pillow tesseract tesseract-data-eng
```
Any linux with GUI support. it launches your firefox.
**NOTE:** Run `tesseract example.png out.txt` and MAKE SURE it works! The result MUST be `8518`.
### WARNING: While making this script, I assume that your system language is ENGLISH
一个不必要的提示:如果你在墙内,用recolic.org代替recolic.net。不然CCP会阻止你的访问。
......
example.png

239 B

from PIL import Image
import sys
i, o = sys.argv[1:]
im = Image.open(i)
# In pass.hust.edu.cn verification code, the second frame is COMPLETE!
# let's get the second frame.
im.seek(im.tell()+1)
im.save(o)
im = Image.open(o)
# To white-black
im = im.convert('L')
im = im.point(lambda x: 0 if x<254 else 255, '1')
# Try to crop
w, h = im.size
if w == 90 and h == 58:
im = im.crop((0, 18, w, 39))
else:
print('WARNING: Expected image w=90, h=58, Got image w={}, h={}.'.format(w, h))
# Save for OCR
im.save(o)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment