Skip to content

Conversation

@gtrusler
Copy link

@gtrusler gtrusler commented Dec 1, 2025

Summary

This PR adds support for ORB (Oriented FAST and Rotated BRIEF) feature detection and matching, which enables robust image registration for applications like glare-free photo scanning.

New Functions

  • ORB_create - Creates an ORB feature detector with configurable parameters (nfeatures, scaleFactor, nlevels, etc.)
  • detectAndCompute - Detects keypoints and computes descriptors using the ORB detector
  • BFMatcher_create - Creates a Brute-Force descriptor matcher (with NORM_HAMMING for ORB)
  • matchBF - Finds the best match for each descriptor
  • knnMatchBF - Finds k-nearest matches (useful for Lowe's ratio test)
  • findHomographyFromMatches - Computes perspective transformation from 4 matched point pairs

New Types

  • ORB - ORB detector object
  • BFMatcher - Brute-Force matcher object
  • KeyPointVector - Vector of detected keypoints
  • DMatchVector - Vector of descriptor matches
  • DMatchVectorVector - Vector of match vectors (for knnMatch)

New Constants

  • ORBScoreType - HARRIS_SCORE, FAST_SCORE
  • HomographyMethod - DEFAULT, LMEDS, RANSAC, RHO (for future use)

Implementation Notes

  • Uses cv::getPerspectiveTransform instead of cv::findHomography since the calib3d module is not available in FastOpenCV-iOS pod
  • The findHomographyFromMatches function expects exactly 4 point pairs (caller should pre-filter using ratio test and select well-distributed points)
  • toJSValue converters added for keypoint and match data structures

Use Case

This enables Google PhotoScan-style image alignment using feature matching + homography:

  1. Detect ORB features in reference and target images
  2. Match descriptors using BFMatcher
  3. Apply Lowe's ratio test to filter good matches
  4. Select 4 well-distributed points
  5. Compute homography and warp target to align with reference

Testing

  • iOS build verified: 0 errors, compiles cleanly
  • TypeScript types exported correctly

🤖 Generated with Claude Code

gtrusler and others added 3 commits November 30, 2025 23:43
Adds support for:
- ORB_create() with full parameter support for feature detection
- detectAndCompute() for keypoint + descriptor extraction
- BFMatcher_create() for Hamming distance matching
- matchBF() and knnMatchBF() for descriptor matching
- findHomography() with RANSAC support

New object types:
- ORB (feature detector)
- BFMatcher (descriptor matcher)
- KeyPointVector (detected keypoints)
- DMatchVector (descriptor matches)
- DMatchVectorVector (for knnMatch results)

New constants:
- ORBScoreType (HARRIS_SCORE, FAST_SCORE)
- NormTypes (NORM_HAMMING, NORM_L2, etc.)
- HomographyMethod (RANSAC, LMEDS, RHO)

These functions enable robust image registration for
applications like photo scanning and panorama stitching.

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

Co-Authored-By: Claude <noreply@anthropic.com>
calib3d module is not included in FastOpenCV-iOS pod.
Replaced findHomography with findHomographyFromMatches which uses
getPerspectiveTransform from imgproc module.

The caller must provide exactly 4 point pairs (pre-filtered best matches).
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.

1 participant