# cv2.error: OpenCV(4.5.5) /tmp/opencv-4.5.5/modules/xfeatures2d/src/sift.cpp:120: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'SIFT_create'

- **ID:** `opencv/sift-patent-expired-license`
- **Domain:** opencv
- **Category:** build_error
- **Error Code:** `-213`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

SIFT algorithm is disabled by default in OpenCV builds due to patent restrictions; non-free modules must be enabled at compile time.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## Workarounds

1. **Install opencv-contrib-python which includes non-free modules by default: `pip install opencv-contrib-python`** (90% success)
   ```
   Install opencv-contrib-python which includes non-free modules by default: `pip install opencv-contrib-python`
   ```
2. **Rebuild OpenCV from source with CMake flag: `cmake -DOPENCV_ENABLE_NONFREE=ON ..` then `make -j8` and `sudo make install`** (85% success)
   ```
   Rebuild OpenCV from source with CMake flag: `cmake -DOPENCV_ENABLE_NONFREE=ON ..` then `make -j8` and `sudo make install`
   ```
3. **Use AKAZE or ORB as patent-free alternatives: `akaze = cv2.AKAZE_create(); kp, des = akaze.detectAndCompute(img, None)`** (70% success)
   ```
   Use AKAZE or ORB as patent-free alternatives: `akaze = cv2.AKAZE_create(); kp, des = akaze.detectAndCompute(img, None)`
   ```

## Dead Ends

- **** — Pip install opencv-python-headless doesn't include non-free modules; SIFT remains unavailable. (70% fail)
- **** — Setting OPENCV_ENABLE_NONFREE=ON via environment variable won't affect pre-built binary packages. (90% fail)
- **** — Using cv2.xfeatures2d.SIFT_create() still requires non-free build; the function name doesn't change behavior. (80% fail)
