def __init__(self,frame,rect,method='m'):
r,c,h,w=rect
roi = frame[r:r+h, c:c+w]
mask = cv2.inRange(roi, np.array((0.)), np.array((255.)))
roi_hist = cv2.calcHist([roi],[0],mask,[16],[0,255])
roi_hist=cv2.normalize(roi_hist,roi_hist,0,255,cv2.NORM_MINMAX)
plotRects(frame,[rect])
cv2.waitKey(0)
cv2.destroyAllWindows()
self.roi_hist=roi_hist
self.track_window=tuple(rect)
self.m=method
self.frame=frame
评论列表
文章目录