reset
This commit is contained in:
parent
d8553d4a84
commit
2fed9ad474
1 changed files with 21 additions and 29 deletions
|
|
@ -198,58 +198,50 @@ class StitchingScanner:
|
|||
|
||||
return result
|
||||
|
||||
else: # append_left - place at x_offset position
|
||||
# x_offset represents where camera's LEFT edge is in mosaic coordinates
|
||||
# For LEFT scanning, we pass abs(current_x) as x_offset
|
||||
# The strip covers content from x_offset leftward
|
||||
|
||||
else: # append_left - place at x_offset, NO width expansion
|
||||
# x_offset is where the LEFT edge of the strip should go
|
||||
if x_offset is None:
|
||||
x_offset = 0
|
||||
|
||||
# Clamp x_offset to valid range
|
||||
x_offset = 0 - min(x_offset, w_base - blend_w)
|
||||
|
||||
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" x_offset (camera left edge): {x_offset}, y_offset: {y_offset}, blend_w: {blend_w}")
|
||||
self.log(f" x_offset: {x_offset}, y_offset: {y_offset}, blend_w: {blend_w}")
|
||||
|
||||
# Result is same size as base (no expansion when going left)
|
||||
result = base.copy()
|
||||
|
||||
# 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_x_end = min(x_offset + blend_w, w_base) # Right edge with blend zone
|
||||
strip_x_start = max(0, strip_x_end - w_strip)
|
||||
|
||||
actual_strip_width = strip_x_end - strip_x_start
|
||||
# Calculate placement bounds
|
||||
strip_x_start = x_offset
|
||||
strip_x_end = min(x_offset + w_strip, w_base)
|
||||
strip_cols_to_copy = 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" Actual strip width: {actual_strip_width}")
|
||||
self.log(f" Strip cols to copy: {strip_cols_to_copy}")
|
||||
|
||||
if actual_strip_width <= blend_w:
|
||||
self.log(f" Strip too narrow, skipping")
|
||||
return result
|
||||
# Step 1: Copy strip content (non-blend portion) at correct position
|
||||
# For LEFT scanning, blend is on the RIGHT side of the strip
|
||||
non_blend_end = strip_cols_to_copy - blend_w
|
||||
if non_blend_end > 0:
|
||||
result[y_offset:y_offset + h_strip, strip_x_start:strip_x_start + non_blend_end] = strip[:, :non_blend_end]
|
||||
self.log(f" Step 1: Placed non-blend at X={strip_x_start}:{strip_x_start + non_blend_end}")
|
||||
|
||||
# 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
|
||||
# Step 2: Create blend on the RIGHT edge of strip (blending with existing content)
|
||||
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)
|
||||
strip_overlap = strip[:, -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}")
|
||||
self.log(f" Final: Strip placed at X={strip_x_start}, Y={y_offset}, mosaic size unchanged: {w_base}x{h_base}")
|
||||
return result
|
||||
|
||||
def _blend_horizontal(self, base: np.ndarray, strip: np.ndarray,
|
||||
|
|
@ -431,7 +423,7 @@ class StitchingScanner:
|
|||
strip_end = min(w, append_width + BLEND_WIDTH)
|
||||
new_strip = frame[:, :strip_end]
|
||||
self.mosaic = self._blend_horizontal_at_y(
|
||||
self.mosaic, new_strip, BLEND_WIDTH, append_right=False, x_offset=int(abs(self.state.current_x)), y_offset=y_offset)
|
||||
self.mosaic, new_strip, BLEND_WIDTH, append_right=False, x_offset=int(self.state.current_x), y_offset=y_offset)
|
||||
|
||||
self._displacement_since_append_x = fractional_remainder
|
||||
self._displacement_since_append_y = 0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue