Skip to content

feat: implement automatic edge overlap detection - #2

Merged
sunalan2025 merged 1 commit into
mainfrom
feature/auto-overlap-detection-480113580496954260
Aug 3, 2026
Merged

feat: implement automatic edge overlap detection#2
sunalan2025 merged 1 commit into
mainfrom
feature/auto-overlap-detection-480113580496954260

Conversation

@sunalan2025

Copy link
Copy Markdown
Owner
  • Updated detectOverlap to evaluate image scanlines synchronously using Mean Absolute Difference (MAD).
  • Added logic in App.tsx (handleImagesChange) to automatically detect and assign overlap properties to sequentially adjacent images right upon upload.
  • Implemented a fallback in the overlap algorithm to return 0 when match difference falls beyond the acceptable threshold.
  • Added a "✨ 智能自动对齐 (Auto Align)" trigger button to the UI Control Panel to invoke manual blanket auto-alignment over all loaded images.

PR created automatically by Jules for task 480113580496954260 started by @sunalan2025

- Updated `detectOverlap` algorithm to use Mean Absolute Difference (MAD) synchronously.
- Automatically calculate overlaps between adjacent image items upon upload in `App.tsx`.
- Added an "Auto Align" (智能自动对齐) button in `ControlPanel.tsx` to manually trigger alignment of all images.
- Implemented fallback to 0 overlap when matching confidence is low.

Co-authored-by: sunalan2025 <255776802+sunalan2025@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings July 31, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds “smart” overlap detection and auto-alignment to the stitching workflow by updating the overlap algorithm and triggering overlap estimation automatically on upload/reorder flows, plus adding a manual UI trigger for blanket auto-alignment.

Changes:

  • Reworked detectOverlap to use MAD-based scanline comparison and return 0 when matches exceed a threshold.
  • Updated App.tsx image-change handling to auto-detect overlaps for adjacent images during uploads.
  • Added an “✨ 智能自动对齐 (Auto Align)” trigger button in the Control Panel UI.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/utils/stitching.ts Updates overlap detection algorithm (MAD) and threshold fallback behavior.
src/App.tsx Auto-detects and assigns overlaps when images change (e.g., upload).
src/components/ControlPanel.tsx Adds a manual “Auto Align” trigger button to the Stitch tab UI.
package-lock.json Lockfile updates reflecting dependency graph changes.
Suppressed comments (1)

src/App.tsx:149

  • If loadImage/detectOverlap fails for an index that already exists in newOverlaps, the catch block currently leaves the previous value intact (only pushes when the array is shorter). That can keep a stale overlap for a changed image pair; explicitly set the existing entry to 0 on error.
        } catch (e) {
          console.error("Error pre-calculating overlap", e);
          if (newOverlaps.length <= i) newOverlaps.push(0);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/App.tsx
Comment on lines +131 to +135
// Automatically detect overlap for new additions
const oldLen = images.length;
const newLen = newImgs.length;

for (let i = oldLen > 1 ? oldLen - 1 : 0; i < newLen - 1; i++) {
Comment thread src/utils/stitching.ts
Comment on lines 24 to +28
const sampleWidth = 120; // Width of the sample strip in center
const maxOverlap = Math.min(imgA.naturalHeight, imgB.naturalHeight, 600);

const getWidth = (img: any) => img.naturalWidth || img.videoWidth || img.width;
const getHeight = (img: any) => img.naturalHeight || img.videoHeight || img.height;

Comment thread src/utils/stitching.ts
Comment on lines 123 to 127
// If the match difference is too high, it's likely they don't overlap
// 350 is a reasonable empirical threshold for average squared difference per color channel
if (minDifference > 500) {
// 40 is a reasonable empirical threshold for average absolute difference for 3 color channels
if (minDifference > 40) {
return 0;
}
@sunalan2025
sunalan2025 merged commit 3cee9b7 into main Aug 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants