Add SIFT feature detector TypeScript definitions and enable NONFREE build flag
Adds TypeScript type definitions for SIFT (Scale-Invariant Feature Transform) feature detector. SIFT patent expired in 2020 but requires OpenCV built with OPENCV_ENABLE_NONFREE=ON.
Changes
Type Definitions (src/types/opencv/SIFT.ts)
-
SIFTclass extendingFeature2Dwith 5 optional constructor parameters matching OpenCV 4.12 API - Exported via
_types.ts
Build Configuration (.github/workflows/build-opencv.yml)
- Added
--cmake_option="-DOPENCV_ENABLE_NONFREE=ON"to enable SIFT in future opencv.js builds
Documentation (README.md)
- Feature detection section with SIFT usage example and memory management patterns
Tests (test/SIFT.test.ts)
- Type definition validation (runs now)
- Runtime functionality tests (skipped until opencv.js rebuilt with NONFREE enabled)
Usage
const sift = new cv.SIFT(
500, // nfeatures
3, // nOctaveLayers
0.04, // contrastThreshold
10, // edgeThreshold
1.6 // sigma
);
const keypoints = new cv.KeyPointVector();
const descriptors = new cv.Mat();
sift.detectAndCompute(gray, new cv.Mat(), keypoints, descriptors);
console.log(`Found ${keypoints.size()} keypoints with ${descriptors.cols}-dim descriptors`);
// Cleanup
keypoints.delete();
descriptors.delete();
sift.delete();
Note: Full SIFT functionality requires rebuilding opencv.js binary with updated workflow. TypeScript definitions work immediately.
Original prompt
This section details on the original issue you should resolve
<issue_title>could including SIFT function</issue_title> <issue_description></issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes TechStark/opencv-js#62
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.