Module 'cv2.cv2' has no attribute 'sfm'

Unable to use sfm with opencv-python.

import cv2
help(cv2.sfm)

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'cv2.cv2' has no attribute 'sfm'

I want to use the sfm component. I tried building from source but I do not know what build options I should set in order to use the python bindings for the sfm functions of opencv. I also tried pip install opencv-contrib-python but this also doesn’t install the sfm components

the sfm module is in opencv_contrib. it also has a lot of dependancies, so

  • you cannot install this via pip (not even opencv_contrib_python)
  • you have to build from src, with the following deps installed:
    • Ceres
    • Glog
    • GFlags

good luck !