I have REST API in Python Flask server which takes a video from the POST request and performs some emotional recognition using OpenCV and return a JSON response with the emotional data.
But the OpenCV documentation doesn't provide any way to read the Video from its string representation. It either takes webcam or a url but there is no mention about the video in string representation.
I have tried saving the video file in my server local and then using that saved file to complete my processing but this doesn't look efficient since we need to scale the feature for multiple users.
Is there any way to directly utilise the video in its string representation and process it frame by frame rather than saving it to local and using it.
Below is how I am trying to do it.
@app.route('/processCapturedVideo', methods = ['POST'])
def processCapturedVideo():
# Read as the video file from post request form data
fileStr = request.files['file'].read()
# Process the video in string format using OpenCV and get the result
return {'data': result}, 200
If not for OpenCV, I am open for suggestion regarding the alternatives, only that the video needs to processed frame by frame.