示例#1
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)
        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
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