- Add project constitution with vision, principles, and autonomy settings - Add 15 feature specifications covering full app scope - Configure agent entry points (AGENTS.md, CLAUDE.md) - Add build prompt and speckit command for spec creation - Include comprehensive .gitignore for iOS development Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1.4 KiB
1.4 KiB
Masking Service
Description
Wrapper around Vision framework for generating masks from user taps and contour detection.
Acceptance Criteria
MaskingServiceclass with methods:func generatePersonMask(at point: CGPoint, in image: CGImage) async throws -> CGImage?func generateForegroundMask(at point: CGPoint, in image: CGImage) async throws -> CGImage?func detectContours(in image: CGImage) async throws -> [VNContour]
- Uses
VNGenerateForegroundInstanceMaskRequestfor person/object masks - Uses
VNDetectContoursRequestfor wire/line detection - Mask dilation method:
func dilate(mask: CGImage, by pixels: Int) -> CGImage - Mask feathering method:
func feather(mask: CGImage, amount: Float) -> CGImage - Returns
nilwhen no mask detected at tap location (not an error) - Unit tests for mask operations
Technical Notes
VNGenerateForegroundInstanceMaskRequestrequires iOS 17+- Point coordinates must be normalized (0-1) for Vision requests
- Instance masks can identify multiple separate foreground objects
- Use
indexesOfInstancesContainingPointto find which instance was tapped
Edge Cases
- No person/object at tap location: return nil, caller shows fallback UI
- Multiple overlapping instances: return the one containing the tap point
- Vision request fails: throw descriptive error
- Image orientation: ensure coordinates are transformed correctly