title: How to capture picture of client and save it on server using flask?
body: <pre><code>from flask import Flask, Response
  import cv2
  class Camera(object):
    def __init__(self):
      self.cap = cv2.VideoCapture(0)
  
    def get_frame(self):
      ret, frame = self.cap.read()
      return open('stream.jpg', 'rb').read()
  
  
  app = Flask(__name__)
  
  def gen(camera):
    while True:
      frame = camera.get_frame()
      yield (b'--frame\r\n'
        b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
  
  @app.route('/')
  def video_feed():
    return Response(gen(Camera()),
    mimetype='multipart/x-mixed-replace;boundary=frame') 
  
  if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)
  </code></pre>
  
  <p>I want to capture every frame per second and save it to file upto 20 images how can I do it? Can Anyone suggest proper code for that?</p>