Merge branch 'master' into dev
This commit is contained in:
+25
-10
@@ -96,6 +96,7 @@ class Sensor:
|
||||
self.img = None
|
||||
self.img_size_raw = None
|
||||
self.img_filtered = None
|
||||
self.prev_img = None
|
||||
self.flow = None
|
||||
self.vnormal = None
|
||||
self.vshear = None
|
||||
@@ -185,23 +186,37 @@ class Sensor:
|
||||
# Resize
|
||||
img = cv2.resize(img, tuple(self._config_resolution_stitch), interpolation=cv2.INTER_CUBIC)
|
||||
|
||||
# Temporal filtering (noise reduction)
|
||||
alpha = 0.7
|
||||
if self.img_filtered is None:
|
||||
self.img_filtered = img.astype(np.float32)
|
||||
else:
|
||||
self.img_filtered = alpha * img + (1 - alpha) * self.img_filtered
|
||||
|
||||
self.img = self.img_filtered.astype(np.uint8)
|
||||
# # Temporal filtering (noise reduction)
|
||||
# alpha = 0.7
|
||||
# if self.img_filtered is None:
|
||||
# self.img_filtered = img.astype(np.float32)
|
||||
# else:
|
||||
# self.img_filtered = alpha * img + (1 - alpha) * self.img_filtered
|
||||
# Update previous image
|
||||
if self.mirror:
|
||||
img = cv2.flip(img, 1)
|
||||
|
||||
if self.img is not None:
|
||||
self.prev_img = self.img.copy()
|
||||
|
||||
self.img = img.astype(np.uint8)
|
||||
|
||||
if self.prev_img is None:
|
||||
self.prev_img = img.copy()
|
||||
|
||||
if log_timing:
|
||||
timings['total'] = (time.perf_counter() - t_start) * 1000
|
||||
self._print_timings("get_img", timings)
|
||||
if self.mirror:
|
||||
self.img = cv2.flip(self.img, 1)
|
||||
|
||||
|
||||
return self.img.copy()
|
||||
|
||||
def detect_motion(self, threshold=10):
|
||||
if self.prev_img is None:
|
||||
return False
|
||||
diff = cv2.absdiff(self.img, self.prev_img)
|
||||
return diff.mean() > threshold
|
||||
|
||||
def compute_deformation(self):
|
||||
"""
|
||||
Compute optical flow and decompose into force components.
|
||||
|
||||
Reference in New Issue
Block a user