Пример #1
0
def upload_file():
    files = request.files
    res = filemanager.upload_file(files)
    if res["status"] == "success":
        name = res["detail"]["name"]
        id = res["detail"]["id"]
        save_path = filemanager.get_save_path(id)
        cutout_res = cutout_face(save_path,name,save_path)
        if cutout_res["status"] == "error":
            return put_response(cutout_res)
        else:
            res["detail"]["faceTotal"] = cutout_res["detail"]["number"]
        circum_res = circumscribe_face(save_path,name,save_path)
        if circum_res["status"] == "error":
            return put_response(circum_res)
    return put_response(res)
Пример #2
0
def update_recipe(recipe_id):
    content_type = request.get_header('Content-Type')
    if content_type == "application/json":
        obj = request.json
        res = fm.update_recipe(recipe_id, obj)
    else:
        res = {"status": "error"}
    return put_response(res)
Пример #3
0
def upload_file():
    files = request.files
    res = fm.upload_file(files)
    if res["status"] == "success":
        name = res["detail"]["name"]
        id = res["detail"]["id"]
        save_path = fm.get_save_path(id)
        cutout_res = cutout_face(save_path, name, save_path)
        if cutout_res["status"] == "error":
            return put_response(cutout_res)
        else:
            res["detail"]["faceTotal"] = cutout_res["detail"]["number"]
        circum_res = circumscribe_face(save_path, name, save_path)
        if circum_res["status"] == "error":
            return put_response(circum_res)
    print(res)
    return put_response(res)
Пример #4
0
def get_rectangle_indiviual(image_id, number):
    name = get_face_image_name(image_id, type="rect", full_path=False)
    save_path = fm.get_save_path(image_id)
    res = circumscribe_face(save_path, name[5:], save_path, int(number))
    fullpath = save_path + "/" + name
    with open(fullpath) as f:
        image = f.read()
    content_type = fm.get_content_type(fullpath)
    return put_response(image, content_type=content_type)
Пример #5
0
def get_rectangle_indiviual(image_id, number):
    name = get_face_image_name(image_id, type="rect", full_path=False)
    save_path = filemanager.get_save_path(image_id)
    res = circumscribe_face(save_path, name[5:], save_path, int(number))
    fullpath = save_path + "/" + name;
    with open(fullpath) as f:
        image = f.read()
    content_type = filemanager.get_content_type(fullpath)
    return put_response(image, content_type=content_type)
Пример #6
0
def read_static(file_type, file):
    if file_type == "js":
        content_type = "text/javascript"
    elif file_type == "css":
        content_type = "text/css"
    else:
        content_type = "text/html"
    with open('../static/' + file_type + '/' + file) as f:
        data = f.read()
    return put_response(data=data, content_type=content_type)
Пример #7
0
def read_static(file_type, file):
    if file_type == "js":
        content_type = "text/javascript"
    elif file_type == "css":
        content_type = "text/css"
    else:
        content_type = "text/html"
    with open('../static/'+file_type+'/'+file) as f:
        data = f.read()
    return put_response(data=data, content_type=content_type)
Пример #8
0
def delete_recipe(recipe_id):
    res = fm.delete_recipe(recipe_id)
    return put_response(res)
Пример #9
0
def get_recipe(recipe_id):
    res = fm.get_recipe(recipe_id)
    return put_response(res)
Пример #10
0
def get_recipes_list():
    offset = request.params.get("offset", 0)
    limit = request.params.get("limit")
    res = fm.get_recipe_list(offset, limit)
    return put_response(res)
Пример #11
0
def get_probability(image_id):
    res = prob.get_prob(image_id)
    return put_response(res)
Пример #12
0
def get_rectangle(image_id):
    fullpath = get_face_image_name(image_id, type="rect")
    with open(fullpath) as f:
        image = f.read()
    content_type = fm.get_content_type(fullpath)
    return put_response(image, content_type=content_type)
Пример #13
0
def get_face(image_id, number):
    fullpath = get_face_image_name(image_id, number)
    with open(fullpath) as f:
        image = f.read()
    content_type = fm.get_content_type(fullpath)
    return put_response(image, content_type=content_type)
Пример #14
0
def get_probability(image_id):
    res = prob.get_prob(image_id)
    return put_response(res)
Пример #15
0
def get_rectangle(image_id):
    fullpath = get_face_image_name(image_id,type="rect")
    with open(fullpath) as f:
        image = f.read()
    content_type = filemanager.get_content_type(fullpath)
    return put_response(image, content_type=content_type)