版本暂存
This commit is contained in:
32
test/test_ocr.py
Normal file
32
test/test_ocr.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import zmq
|
||||
|
||||
|
||||
context = zmq.Context()
|
||||
socket = context.socket(zmq.REQ)
|
||||
socket.connect("tcp://localhost:6668")
|
||||
|
||||
filter_w = (213, 540)
|
||||
filter_h = (120, 360)
|
||||
|
||||
|
||||
while True:
|
||||
a = input("")
|
||||
socket.send_string("")
|
||||
resp = socket.recv_pyobj()
|
||||
print(resp)
|
||||
if resp.get('code') == 0:
|
||||
text = ''
|
||||
for item in resp.get('content'):
|
||||
if item['probability']['average'] < 0.90:
|
||||
continue
|
||||
box = item['location']
|
||||
center_x = box['left'] + box['width'] / 2
|
||||
center_y = box['top'] + box['height'] / 2
|
||||
if center_x < filter_w[0] or center_x > filter_w[1] \
|
||||
or center_y < filter_h[0] or center_y > filter_h[1]:
|
||||
continue
|
||||
text += item['words']
|
||||
print(text)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user