I made a small python app for face recognition and now I am converting it into a flask application.
@app.route('/save', methods=['POST'])
def save_image():
if request.method == 'POST':
if 'imageFile' not in request.files:
return {"detail": "No file found"}, 400
image = request.files['imageFile']
imageFileName = secure_filename(image.filename)
image.save('./images/' + imageFileName)
image = cv2.imread('./images/' + imageFileName)
image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
face_encoding = face_recognition.face_encodings(image)[0]
np.savetxt('./encodings/' + request.form['indexNumber'] + '.csv', face_encoding, delimiter=',')
return 'saving image'
In the above code I have saved the image posted to the server and read it again using cv2.imread and have later used it to create the face encoding. What I want is to do this without saving the image in the server. Is there a way to directly read the image posted and use like above?