def webcam_upload():
    data = request.get_json()

    # Preprocess the upload image
    img_raw = data['data-uri'].encode()
    image_path = parse_image(img_raw)
    print(image_path)
    (categoryPredict, positions) = detect(image_path)
    print(categoryPredict)

    if len(categoryPredict) > 0:
        croppedDectection = []
        for i in range(len(categoryPredict)):
            croppedDectection.append(
                'static/images/cropped-dectecion-{}.jpg'.format(i))

        croppedObject = cropped.list_object(
            zip(categoryPredict, croppedDectection))
    else:
        croppedDectection = None

    objectDetection = 'static/images/object-detection.jpg'

    os.remove(image_path)

    return {
        "crop": croppedDectection,
        "full": objectDetection,
        "details": positions
    }
示例#2
0
def video():
    if request.method == "POST":
        print(request)
        _ = VideoCamera().get_frame(capture=True)

        categoryPredict = detect('static/images/object-detection.jpg')

        if len(categoryPredict) > 0:
            croppedDectection = []
            for i in range(len(categoryPredict)):
                croppedDectection.append(
                    'images/cropped-dectecion-{}.jpg'.format(i))

            croppedObject = cropped.list_object(
                zip(categoryPredict, croppedDectection))
        else:
            croppedObject = None

        return render_template('home.html',
                               f='../static/images/object-detection.jpg',
                               c=croppedObject)

    return render_template('home.html', f=None, c=[])
示例#3
0
def still():
    if request.method == "POST":
        f = request.files["uploadfile"]

        _, ext = os.path.splitext(f.filename)
        if os.path.exists(os.path.join(ptuf, "input" + ext)):
            os.remove(os.path.join(ptuf, "input" + ext))

        f.save(os.path.join(ptuf, "input" + ext))

        categoryPredict = detect('static\images\input' + ext)
        if len(categoryPredict) > 0:
            croppedDectection = []
            for i in range(len(categoryPredict)):
                croppedDectection.append(
                    'images/cropped-dectecion-{}{}'.format(i, ext))

            croppedObject = cropped.list_object(
                zip(categoryPredict, croppedDectection))
        else:
            croppedObject = None

        objectDetection = 'images/object-detection' + ext

        return render_template('still.html',
                               f=objectDetection,
                               c=croppedObject)

    df = pd.read_csv('static/product-data/Sofa bed.csv')

    for category in ['Chair', 'Table', 'Lamp', 'Shelf']:
        df.append(pd.read_csv('static/product-data/{}.csv'.format(category)))

    randomProducts = products.random_products(df, 10)

    return render_template('still.html', r=randomProducts)
def still():
    if request.method == "POST":
        f = request.files["uploadfile"]

        _, ext = os.path.splitext(f.filename)
        if os.path.exists(os.path.join(ptuf, "input" + ext)):
            os.remove(os.path.join(ptuf, "input" + ext))

        f.save(os.path.join(ptuf, "input" + ext))

        categoryPredict = detect('static/images/input.jpg')
        if len(categoryPredict) > 0:
            croppedDectection = []
            for i in range(len(categoryPredict)):
                croppedDectection.append(
                    'images/cropped-dectecion-{}.jpg'.format(i))

            croppedObject = cropped.list_object(
                zip(categoryPredict, croppedDectection))
        else:
            croppedObject = None

        objectDetection = 'images/object-detection.jpg'

        return render_template('still.html',
                               f=objectDetection,
                               c=croppedObject)

    df = pd.read_csv('static/product-data/top.csv')

    for category in ['dress', 'shorts', 'skirt', 'trousers']:
        df.append(pd.read_csv('static/product-data/{}.csv'.format(category)))

    randomProducts = products.random_products(df, 10)

    return render_template('still.html', r=randomProducts)