tail frame

This commit is contained in:
bluepulsar
2026-04-14 19:53:08 +08:00
parent 424a4e37ce
commit f5c92f3ea0
+9 -6
View File
@@ -117,6 +117,7 @@ class Sensor:
shape = (self.__config_cam["resolution_stitch"][1], self.__config_cam["resolution_stitch"][0]) shape = (self.__config_cam["resolution_stitch"][1], self.__config_cam["resolution_stitch"][0])
self.img_size_raw = None self.img_size_raw = None
self.img_filtered = None self.img_filtered = None
self.tail_frames_count = 0
# Optical Flow Data Variables (public) # Optical Flow Data Variables (public)
self.flow = np.zeros(shape + (2,), dtype=np.float32) self.flow = np.zeros(shape + (2,), dtype=np.float32)
@@ -207,7 +208,7 @@ class Sensor:
if not ret: if not ret:
print("Failed to get_img from video source.") print("Failed to get_img from video source.")
return None return False
# Start processing timing # Start processing timing
t_processing_start = time.perf_counter() t_processing_start = time.perf_counter()
@@ -246,7 +247,7 @@ class Sensor:
self._fps = 1.0 / (time.perf_counter() - self.last_log_time) self._fps = 1.0 / (time.perf_counter() - self.last_log_time)
self.last_log_time = time.perf_counter() self.last_log_time = time.perf_counter()
return self.img.copy() return True
def detect_motion(self, threshold=6): def detect_motion(self, threshold=6):
@@ -255,7 +256,7 @@ class Sensor:
# print(f"mag: {mag.max()}, {mag.min()}, {mag.mean()}") # print(f"mag: {mag.max()}, {mag.min()}, {mag.mean()}")
return mag.mean() > threshold return mag.mean() > threshold
def compute_deformation(self, decompose=True, check_motion=True, threshold=6): def compute_deformation(self, decompose=True, check_motion=True, threshold=6, tail_frames=10):
""" """
Compute optical flow and decompose into force components. Compute optical flow and decompose into force components.
@@ -269,13 +270,15 @@ class Sensor:
# self.compute_hhd() # self.compute_hhd()
if check_motion: if check_motion:
if self.detect_motion(threshold=threshold): if self.detect_motion(threshold=threshold):
self.tail_frames_count = 0
self.compute_hhd() self.compute_hhd()
return True return True
else: else:
return False if self.tail_frames_count <= tail_frames:
else: self.tail_frames_count +=1
if decompose:
self.compute_hhd() self.compute_hhd()
return True
return False
return None return None
# return True # return True