Skip to content

Conversation

@ebowwa
Copy link

@ebowwa ebowwa commented Jan 6, 2026

Summary

Fixes detection boxes appearing as vertical lines when video is letterboxed or pillarboxed.

Problem

Detection coordinates are normalized to original video dimensions, but were being transformed using the container geometry size. This caused incorrect rendering when the video aspect ratio differed from the container.

Solution

Modified prepareObjectForSwiftUI to accept an optional videoSize parameter:

  • Uses actual video dimensions for coordinate transformation
  • Scales transformed coordinates to fit the container geometry
  • Maintains backward compatibility

Changes

  • Base.swift: Updated prepareObjectForSwiftUI with videoSize parameter
  • DetectionView.swift: Pass videoSize through to coordinate transformation
  • Added documentation explaining the bug

Test Plan

  • ✅ Build succeeds
  • ✅ App launches correctly
  • ✅ Detection boxes now render with proper aspect ratios

Related

Fixes: #3
Documentation: https://github.com/ebowwa/CoreMLPlayer/blob/fix/detection-box-rendering/docs/bug-detection-box-rendering.md

🤖 Generated with Claude Code

The getVideoRect() function returns CGRect (non-optional), but the code
was using 'if let' optional binding. Changed to direct assignment since
the return value is not optional.

Fixes build error: "initializer for conditional binding must have
Optional type, not 'CGRect'"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Detection boxes were appearing as vertical lines because coordinates
were being transformed using the container geometry size instead of
the actual video dimensions.

Root cause:
- Detection coordinates are normalized to original video dimensions
- But coordinate transformation used container geometry size
- This caused incorrect scaling when video had letterboxing/pillarboxing

Solution:
- Pass videoSize to prepareObjectForSwiftUI for correct transformation
- Scale transformed coordinates to fit the container geometry
- Maintain backward compatibility with optional parameter

Fixes: andrewginns#3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ebowwa ebowwa force-pushed the fix/detection-box-rendering branch from 4c2de76 to a792910 Compare January 6, 2026 20:04
…dering

# Conflicts:
#	CoreMLPlayer/Views/SubViews/DetectionView.swift
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.

ML proposal localizations not appearing correctly

1 participant