mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-04-18 13:00:18 +00:00
chore: update README
This commit is contained in:
parent
58d5022952
commit
288ccddfa1
30
README.md
30
README.md
@ -3,26 +3,32 @@
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from arcaea_offline_ocr.device.v2.rois import DeviceV2AutoRois
|
|
||||||
from arcaea_offline_ocr.device.v2.ocr import DeviceV2Ocr
|
|
||||||
from arcaea_offline_ocr.sift_db import SIFTDatabase
|
|
||||||
from arcaea_offline_ocr.utils import imread_unicode
|
|
||||||
import cv2
|
import cv2
|
||||||
|
from arcaea_offline_ocr.device.ocr import DeviceOcr
|
||||||
|
from arcaea_offline_ocr.device.rois.definition import DeviceRoisAutoT2
|
||||||
|
from arcaea_offline_ocr.device.rois.extractor import DeviceRoisExtractor
|
||||||
|
from arcaea_offline_ocr.device.rois.masker import DeviceRoisMaskerAutoT2
|
||||||
|
from arcaea_offline_ocr.phash_db import ImagePhashDatabase
|
||||||
|
|
||||||
knn_model = cv2.ml.KNearest_load(r'/path/to/knn/model')
|
img_path = "/path/to/opencv/supported/image/formats.jpg"
|
||||||
sift_db = SIFTDatabase(r'/path/to/sift/database.db')
|
img = cv2.imread(img_path, cv2.IMREAD_COLOR)
|
||||||
|
|
||||||
rois = DeviceV2AutoRois(imread_unicode(r'/path/to/your/screenshot.jpg')) # any format that opencv-python supports
|
rois = DeviceRoisAutoT2(img.shape[1], img.shape[0])
|
||||||
ocr = DeviceV2Ocr(knn_model, sift_db)
|
extractor = DeviceRoisExtractor(img, rois)
|
||||||
result = ocr.ocr(rois)
|
masker = DeviceRoisMaskerAutoT2()
|
||||||
print(result)
|
|
||||||
|
knn_model = cv2.ml.KNearest.load("/path/to/trained/knn/model.dat")
|
||||||
|
phash_db = ImagePhashDatabase("/path/to/image/phash/database.db")
|
||||||
|
|
||||||
|
ocr = DeviceOcr(extractor, masker, knn_model, phash_db)
|
||||||
|
print(ocr.ocr())
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ python example.py
|
$ python example.py
|
||||||
DeviceOcrResult(rating_class=2, pure=1371, far=62, lost=34, score=9558078, max_recall=330, song_id='abstrusedilemma', title=None, clear_type=None)
|
DeviceOcrResult(rating_class=2, pure=1135, far=11, lost=0, score=9953016, max_recall=1146, song_id='ringedgenesis', song_id_possibility=0.953125, clear_status=2, partner_id='45', partner_id_possibility=0.8046875)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
[283375/image-sift-database](https://github.com/283375/image-sift-database)
|
[283375/image-phash-database](https://github.com/283375/image-phash-database)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user