correct blur and learning rate
This commit is contained in:
@@ -9,7 +9,9 @@ from cv2util import to_8_bit_image
|
||||
from string import digits as DIGITS
|
||||
|
||||
class BackgroundHeatmap:
|
||||
def __init__(self, first_frame):
|
||||
def __init__(self, first_frame, append_blur=True, learning_rate=0.0003):
|
||||
self.append_blur = append_blur
|
||||
self.learning_rate = learning_rate
|
||||
self.heatmap = np.array([])
|
||||
self.backsub = cv2.createBackgroundSubtractorMOG2()
|
||||
# self.backsub = cv2.createBackgroundSubtractorKNN()
|
||||
@@ -20,7 +22,9 @@ class BackgroundHeatmap:
|
||||
# ret, frame = self.cap.read()
|
||||
# # self.backsub.apply(cv2.blur(frame,(5,5)))
|
||||
# self.backsub.apply(frame)
|
||||
self.lastframe = self.backsub.apply(cv2.blur(first_frame,(5,5))) # don't forget blur here if re applying blur
|
||||
if self.append_blur:
|
||||
frame = cv2.blur(first_frame,(5,5))
|
||||
self.lastframe = self.backsub.apply(frame, self.learning_rate)
|
||||
self.lastsum = self.to_floats(self.lastframe)
|
||||
|
||||
@staticmethod
|
||||
@@ -40,7 +44,9 @@ class BackgroundHeatmap:
|
||||
return cv2.applyColorMap(frame, cv2.COLORMAP_JET)
|
||||
|
||||
def update(self, frame):
|
||||
self.lastframe = self.backsub.apply(cv2.blur(frame,(5,5)))
|
||||
if self.append_blur:
|
||||
frame = cv2.blur(frame,(5,5))
|
||||
self.backsub.apply(frame, self.lastframe, self.learning_rate)
|
||||
self.lastsum += self.to_floats(self.lastframe)
|
||||
self.heatmap = self.gray_to_heat(
|
||||
self.float_to_gray(
|
||||
|
||||
Reference in New Issue
Block a user