I want to apply the particle filter for tracking.. My friend said that I need to find the pdf of color histogram of the video first as a model state.. I already try with these code to show the plot
import cv2
import matplotlib.pyplot as plt
bgsMOG = cv2.BackgroundSubtractorMOG2()
cap = cv2.VideoCapture("d:\MOV_5702.avi")
color=('b','g','r')
if cap:
while True:
ret, frame = cap.read()
for i,col in enumerate(color):
hist = cv2.calcHist([frame],[i],None,[256],[0,256])
plt.plot(hist,color=col)
plt.xlim([0,256])
if ret:
gfmask1=cv2.medianBlur(frame,3)
fgmask = bgsMOG.apply(gfmask1, None, 0.01)
cv2.imshow('Output', frame)
plt.show()
key = cv2.waitKey(400)
if key == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
My question is:
- In the paper I read there's only 1 pdf plot, is bgr histogram produce 1 pdf? If yes, how I can do that? If no, am I just used one channel from bgr?
- The code won't play the next frame, how I can fix it?