continuous drift detection

This commit is contained in:
2ManyProjects 2026-01-11 00:10:43 -06:00
parent 5177eea77e
commit d7bd2fe6cd

View file

@ -191,7 +191,6 @@ class StitchingScanner:
"""
offset = AlignmentOffset()
with self._mosaic_lock:
if self.mosaic is None:
return offset
@ -381,7 +380,8 @@ class StitchingScanner:
y_offset = y_offset - int(round(alignment_y))
# Clamp x_offset to valid range
x_offset = max(0, min(x_offset, w_base - blend_w))
# x_offset = max(0, min(x_offset, w_base - blend_w))
x_offset = 0 - min(x_offset, w_base)
# Handle strip cropping if y_offset is negative (strip protrudes above frame)
strip_y_start = 0 # How much to crop from top of strip
@ -837,7 +837,7 @@ class StitchingScanner:
no_movement_count = 0
max_no_movement = 50
stop_reason = 'stopped'
self.log(f"Scanning 2..")
while self.running and not self.paused:
if time.time() - start_time > self.config.max_scan_time:
self.log("Scan timeout")
@ -871,6 +871,7 @@ class StitchingScanner:
curr_frame = self._capture_frame()
dx, dy = self._detect_displacement_robust(self._prev_frame, curr_frame)
self.log(f"Scanning dx{dx} dy{dy}..")
self._displacement_since_append_x += dx
self._displacement_since_append_y += dy
total_x += dx
@ -885,6 +886,8 @@ class StitchingScanner:
# Edge detection
movement = abs(dx) if direction in [ScanDirection.RIGHT, ScanDirection.LEFT] else abs(dy)
self.log(f"Scanning movement{movement}..")
if movement < 1.0:
no_movement_count += 1
if no_movement_count >= max_no_movement:
@ -896,7 +899,10 @@ class StitchingScanner:
# Append when threshold reached (with continuous alignment)
disp = abs(self._displacement_since_append_x) if direction in [ScanDirection.RIGHT, ScanDirection.LEFT] else abs(self._displacement_since_append_y)
self.log(f"Scanning disp{disp}..")
if disp >= threshold_pixels:
self.log(f"Scanning threshold_pixels..")
self._append_strip(curr_frame, direction)
self.log(f"Appended {disp:.1f}px, mosaic: {self.state.mosaic_width}x{self.state.mosaic_height}, align: ({self._cumulative_align_x:.1f}, {self._cumulative_align_y:.1f})")