Basically, my django app needs to create an image in a view, and pass that to a template. This is easy for a string, but I can't find a way to do it with an image. I have read many stack overflow threads but none quite like mine, which is surprising.
I was trying variations of this as my view:
views.py:
def index(request):
while (True):
#video_capture = cv2.VideoCapture(0)
#ret, frame = video_capture.read()
img = "D:/Desktop/Tap/bsnsFaces.jpg"
frame = cv2.imread(img)
facesNumber ="Found {0} faces!".format(len(faces))
return render(request, 'result.html', {'p': facesNumber}, {'img': frame})`
With the {'img':frame} part at the end not being anywhere close to right. I tried a few things that I found on SO but nothing worked so far. I know that the image is static but eventually I want this to be a frame captured from a webcam so I can't solve this by using models (or can I?).
Thanks in advance for any advice!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Face detection with Django</title>
<p>{{ p }}</p>
<img src="data:image/jpg;base64, {{ img }}"></img>
</head>
<body>
</body>
</html>