예제 #1
0
파일: app.py 프로젝트: zqsmart/darknet-ocr
def job(uid, url, imgString, iscut, isclass, billModel, ip):
    now = get_now()
    if url is not None:
        img = read_url_img(url)
    elif imgString is not None:
        img = base64_to_PIL(imgString)
    else:
        img = None

    if img is not None:
        image = np.array(img)
        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
        boxes, scores = detect_lines(image, scale=scale, maxScale=maxScale)
        data = []
        n = len(boxes)
        for i in range(n):
            box = boxes[i]
            box = [int(x) for x in box]
            if scores[i] > TEXT_LINE_SCORE:
                data.append({
                    'box': box,
                    'prob': round(float(scores[i]), 2),
                    'text': None
                })

        res = {'data': data, 'errCode': 0}
    else:
        res = {'data': [], 'errCode': 3}
    return res
예제 #2
0
파일: app.py 프로젝트: zqsmart/darknet-ocr
 def GET(self):
     post = {}
     now = get_now()
     ip = web.ctx.ip
     post['name'] = u''
     post['billList'] = billList
     post['postName'] = 'text'  ##请求地址
     post['height'] = 500
     post['width'] = 800
     post['textwidth'] = 500
     post['uuid'] = uuid.uuid1().__str__()
     post['url'] = 'text'
     return render.text(post)
예제 #3
0
def job(uid, url, imgString, iscut, isclass, billModel, ip):
    now = get_now()
    if url is not None:
        img = read_url_img(url)
    elif imgString is not None:
        img = base64_to_PIL(imgString)
    else:
        img = None

    if img is not None:
        image = np.array(img)
        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
        data = text_ocr(image, scale, maxScale, TEXT_LINE_SCORE)

        res = {'data': data, 'errCode': 0}
    else:
        res = {'data': [], 'errCode': 3}
    return res