I am trying to use SIFT from OpenCV in a Google Cloud Function. I am encountering an issue due to the fact that SIFT is actually only in opencv-contrib-python for Python 3.
Firebase Logs
File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 346, in run_http_function
result = _function_handler.invoke_user_function(flask.request)
File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 217, in invoke_user_function
return call_user_function(request_or_event)
File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 210, in call_user_function
return self._user_function(request_or_event)
File "/user_code/main.py", line 149, in findMatches
maxMatches = siftMatcher(logoToSearch,cv_imgs[i])
File "/user_code/main.py", line 80, in siftMatcher
sift = cv2.xfeatures2d.SIFT_create()
AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'
requirements.txt
# File: requirements.txt
opencv-python
opencv-contrib-python
...
main.py
# File: main.py
import cv2
...
sift = cv2.xfeatures2d.SIFT_create()