Мне нужно отобразить видеокадр в веб-браузере на странице django html, пожалуйста, сообщите мне, как этого добиться
@gzip.gzip_page
def home(request):
try:
return StreamingHttpResponse(home_video(), content_type="multipart/x-mixed-replace;boundary=frame")
except: # This is bad! replace it with proper handling
pass
def home_video():
cap = cv2.VideoCapture('D:/AI/videoplayback.mp4')
if (cap.isOpened() == False):
print("Error opening video file")
while (cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.resizeWindow('image', 1000, 1000)
cv2.imshow('Frame', frame)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()