Demo entry 6783231

asdas

   

Submitted by anonymous on Feb 04, 2019 at 08:50
Language: Python 3. Code size: 1.0 kB.

 @route('/machine')
def machine_page_tmp():
    return template("/home/valevel/mysite/machine")

@route('/machine', method='POST')
def machine_page_pst():
    mlimg = request.files.get("mlimg")
    fname = mlimg.filename
    filepath = "/home/valevel/mysite/assets/uploaded/"
    mlimg.save(filepath + fname, overwrite = True)
    full_path = filepath + fname
    read_img = cv2.imread(full_path, 1)

    cascPath = "/home/valevel/mysite/haarcascade_frontalface_default.xml"
    faceCascade = cv2.CascadeClassifier(cascPath)
    faces = faceCascade.detectMultiScale(
        read_img,
        scaleFactor = 1.1,
        minNeighbors = 5,
        minSize=(50,50))

    how_many_faces = len(faces)
    for (x, y, w, h) in faces:
        cv2.rectangle(read_img, (x, y), (x+w, y+h), (255, 255, 255), 2)

    cv2.imwrite("/home/valevel/mysite/assets/uploaded/read.png", read_img)
    source = "/static/uploaded/read.png"
    return template("/home/valevel/mysite/machineout", source = source, how_many_faces = how_many_faces)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).