I am trying to show video and it's your own histogram side by side, but my code is not working fine, at least simultaneously:
import cv2
from skimage.io import imread
import numpy as np
import scipy.misc
import matplotlib.pyplot as plt
cap = cv2.VideoCapture('video.mp4')
count = 0
while(cap.isOpened()):
ret, frame = cap.read()
count +=1
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = scipy.misc.imresize(gray, 0.45)
hist = cv2.calcHist([gray],[0],None,[256],[0,256])
cv2.imshow('Gray', gray)
cv2.waitKey(5)
plt.title("Histogram")
plt.plot(hist)
plt.show()
cap.release()
cv2.destroyAllWindows()
How can I do that? I accept any suggestion... My goal is to show two windows (one playing video and another plotting histogram) or just one window with video and histogram side-by-side, maybe with numpy.hstack.