reset ofset

This commit is contained in:
2ManyProjects 2026-01-10 02:19:21 -06:00
parent afd5e8a14c
commit 35c27baafb

View file

@ -199,58 +199,58 @@ class StitchingScanner:
return result return result
else: # append_left - place at x_offset position else: # append_left - place at x_offset position
# x_offset represents where camera's LEFT edge is in mosaic coordinates # x_offset represents where camera's LEFT edge is in mosaic coordinates
# For LEFT scanning, we pass abs(current_x) as x_offset # For LEFT scanning, we pass abs(current_x) as x_offset
# The strip covers content from x_offset leftward # The strip covers content from x_offset leftward
if x_offset is None: if x_offset is None:
x_offset = 0 x_offset = 0
self.log(f"=== _blend_horizontal_at_y (append_left) ===") self.log(f"=== _blend_horizontal_at_y (append_left) ===")
self.log(f" base: {w_base}x{h_base}, strip: {w_strip}x{h_strip}") self.log(f" base: {w_base}x{h_base}, strip: {w_strip}x{h_strip}")
self.log(f" x_offset (camera left edge): {x_offset}, y_offset: {y_offset}, blend_w: {blend_w}") self.log(f" x_offset (camera left edge): {x_offset}, y_offset: {y_offset}, blend_w: {blend_w}")
# Result is same size as base (no expansion when going left) # Result is same size as base (no expansion when going left)
result = base.copy() result = base.copy()
# Strip's RIGHT edge should align with camera's current left edge (x_offset) # Strip's RIGHT edge should align with camera's current left edge (x_offset)
# Strip content goes from (x_offset - w_strip + blend_w) to x_offset # Strip content goes from (x_offset - w_strip + blend_w) to x_offset
strip_x_end = min(x_offset + blend_w, w_base) # Right edge with blend zone strip_x_end = min(x_offset + blend_w, w_base) # Right edge with blend zone
strip_x_start = max(0, strip_x_end - w_strip) strip_x_start = max(0, strip_x_end - w_strip)
actual_strip_width = strip_x_end - strip_x_start actual_strip_width = strip_x_end - strip_x_start
self.log(f" Placing strip at X={strip_x_start}:{strip_x_end}, Y={y_offset}:{y_offset + h_strip}") self.log(f" Placing strip at X={strip_x_start}:{strip_x_end}, Y={y_offset}:{y_offset + h_strip}")
self.log(f" Actual strip width: {actual_strip_width}") self.log(f" Actual strip width: {actual_strip_width}")
if abs(actual_strip_width) <= blend_w: if actual_strip_width <= blend_w:
self.log(f" Strip too narrow, skipping") self.log(f" Strip too narrow, skipping")
return result
# Step 1: Copy non-blend portion of strip
# Strip's left portion (non-blend) goes at strip_x_start
non_blend_width = actual_strip_width - blend_w
if non_blend_width > 0:
# Take from LEFT side of strip (new content)
result[y_offset:y_offset + h_strip, strip_x_start:strip_x_start + non_blend_width] = strip[:, :non_blend_width]
self.log(f" Step 1: Placed {non_blend_width}px non-blend at X={strip_x_start}:{strip_x_start + non_blend_width}")
# Step 2: Blend zone at the RIGHT edge of where we're placing
blend_x_start = strip_x_end - blend_w
blend_x_end = strip_x_end
if blend_w > 0 and blend_x_start >= strip_x_start:
# Alpha: 1 at left (new content) -> 0 at right (existing content)
alpha = np.linspace(1, 0, blend_w, dtype=np.float32)[np.newaxis, :, np.newaxis]
strip_overlap = strip[:, non_blend_width:non_blend_width + blend_w].astype(np.float32)
base_overlap = base[y_offset:y_offset + h_strip, blend_x_start:blend_x_end].astype(np.float32)
blended = (strip_overlap * alpha + base_overlap * (1 - alpha)).astype(np.uint8)
result[y_offset:y_offset + h_strip, blend_x_start:blend_x_end] = blended
self.log(f" Step 2: Blend zone at X={blend_x_start}:{blend_x_end}")
self.log(f" Final: Strip placed at X={strip_x_start}:{strip_x_end}, Y={y_offset}")
return result return result
# Step 1: Copy non-blend portion of strip
# Strip's left portion (non-blend) goes at strip_x_start
non_blend_width = actual_strip_width - blend_w
if non_blend_width > 0:
# Take from LEFT side of strip (new content)
result[y_offset:y_offset + h_strip, strip_x_start:strip_x_start + non_blend_width] = strip[:, :non_blend_width]
self.log(f" Step 1: Placed {non_blend_width}px non-blend at X={strip_x_start}:{strip_x_start + non_blend_width}")
# Step 2: Blend zone at the RIGHT edge of where we're placing
blend_x_start = strip_x_end - blend_w
blend_x_end = strip_x_end
if blend_w > 0 and blend_x_start >= strip_x_start:
# Alpha: 1 at left (new content) -> 0 at right (existing content)
alpha = np.linspace(1, 0, blend_w, dtype=np.float32)[np.newaxis, :, np.newaxis]
strip_overlap = strip[:, non_blend_width:non_blend_width + blend_w].astype(np.float32)
base_overlap = base[y_offset:y_offset + h_strip, blend_x_start:blend_x_end].astype(np.float32)
blended = (strip_overlap * alpha + base_overlap * (1 - alpha)).astype(np.uint8)
result[y_offset:y_offset + h_strip, blend_x_start:blend_x_end] = blended
self.log(f" Step 2: Blend zone at X={blend_x_start}:{blend_x_end}")
self.log(f" Final: Strip placed at X={strip_x_start}:{strip_x_end}, Y={y_offset}")
return result
def _blend_horizontal(self, base: np.ndarray, strip: np.ndarray, def _blend_horizontal(self, base: np.ndarray, strip: np.ndarray,
blend_width: int, append_right: bool) -> np.ndarray: blend_width: int, append_right: bool) -> np.ndarray: