I am capturing an image through webcam using opencv(python 2.7) in my flask application.I want to display this image to the client in the frontend to get coordinates of image on mouseclick.How can i write the functions to send and receive the image via flask and javascript respectively.
flask server code:
from flask import Flask,render_template
import cv2
app = Flask(__name__)
@app.route('/')
def capture_image(self):
self.cam = cv2.VideoCapture(0)
self.img = self.cam.read()
self.cam.release()
render_template(index.html,ob=self.img)
@app.route('/index')
#display image in html
if __name__=='__main__':
app.run()
javascript code:
<html>
<head>
<title> image </title>
</head>
<body>
<img src = "{{ url_for('imagefield') }}">
</body>
</html>