Ejemplo n.º 1
0
def phieldTest():
    data = request.form
    image_data = str(data["image"])
    start = datetime.datetime.now()
    latex = convert_image_to_latex(image_data)
    end = datetime.datetime.now()
    print('recognize time: ' + str((end - start).seconds) + ' s')
    if latex is None:
        print("null")
        return build_resp(code=-1,
                          msg='The provided text can not be recognized.')
    print('recognize result: ' + latex)
    return build_resp(code=0, data={'latex': latex})
Ejemplo n.º 2
0
def recognize():
    json_data = request.form
    image = str(json_data['image'])
    latex = convert_image_to_latex(image)
    if latex is None:
        print("null")
        return build_resp(code=-1,
                          msg='The provided text can not be recognized.')
    print('recognize result: ' + latex)
    # latex_image = latex2image(latex)
    return build_resp(
        code=0,
        data={
            'latex': latex,
            # 'image': latex_image
        })
Ejemplo n.º 3
0
def convert():
    if request.method == 'POST':
        image_uri = request.json.get('image_uri')
        # print(image_uri)
        if image_uri is None:
            return build_resp(code=-1, msg='Param of <image_uri> (image base64) required.')
        latex = convert_image_to_latex(image_uri)
        # print(latex)
        if latex is None:
            print("null")
            return build_resp(code=-1, msg='The provided text can not be recognized.')
        equation = get_latex_equation(latex)
        # print("equation")
        if equation is None:
            return build_resp(code=-1, msg='The provided text can not be recognized.')
        # print("build")
        return build_resp(code=0, data=equation)
Ejemplo n.º 4
0
def convertUnity():
    if request.method == 'POST':
        image_uri = str(request.data.decode())
        latex = convert_image_to_latex(image_uri)
        if latex is None:
            print("null")
            return build_resp(code=-1,
                              msg='The provided text can not be recognized.')
        print('recognize result: ' + latex)
        if '\\rightarrow' not in latex and '\\longrightarrow' not in latex:
            points = calculate_points_set(latex)
        else:
            points = []
        # latex_image = latex2image(latex)
        return build_resp(
            code=0,
            data={
                'latex': latex,
                'points': points,
                # 'image': latex_image
            })
Ejemplo n.º 5
0
def test():
    convert_image_to_latex()
    return 'Converted!'