feat: add --show-events overlay with raw log intensity
Visualize raw temporal brightness change (threshold=0, log domain) as green(+)/red(-) gradient overlay proportional to |change|. Supports video output and live display modes. Enables EventProcessor threshold=0 for raw mode without clipping. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -71,9 +71,14 @@ class EventProcessor:
|
||||
frame: np.ndarray, shape (H, W) or (H, W, C), uint8 or float.
|
||||
|
||||
Returns:
|
||||
events_binary: np.ndarray (H, W), values in {-1, 0, +1}
|
||||
events_strength: np.ndarray (H, W), values in [-1, 1]
|
||||
event_count: int, number of non-zero events
|
||||
When threshold > 0:
|
||||
events_binary: np.ndarray (H, W), values in {-1, 0, +1}
|
||||
events_strength: np.ndarray (H, W), values in [-1, 1]
|
||||
event_count: int, number of non-zero events
|
||||
When threshold == 0 (raw output, no thresholding):
|
||||
change_raw: np.ndarray (H, W), raw log/linear brightness change (float32)
|
||||
change_raw: same as above
|
||||
event_count: int, number of pixels with non-zero change
|
||||
"""
|
||||
brightness = self._to_grayscale(frame)
|
||||
|
||||
@@ -81,10 +86,18 @@ class EventProcessor:
|
||||
if self.prev_brightness is None:
|
||||
self.prev_brightness = brightness
|
||||
h, w = brightness.shape
|
||||
if self.threshold == 0:
|
||||
return np.zeros((h, w), dtype=np.float32), np.zeros((h, w), dtype=np.float32), 0
|
||||
return np.zeros((h, w), dtype=np.int8), np.zeros((h, w), dtype=np.float32), 0
|
||||
|
||||
change = self._compute_change(brightness)
|
||||
|
||||
# threshold == 0: raw mode, skip thresholding
|
||||
if self.threshold == 0:
|
||||
self.prev_brightness = brightness
|
||||
change_f32 = change.astype(np.float32)
|
||||
return change_f32, change_f32, int(np.count_nonzero(change))
|
||||
|
||||
if self.auto_threshold:
|
||||
self._update_auto_threshold(change)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user