python-opencv AttributeError: 'module' object has no attribute 'createBackgroundSubtractorGMG'

后端 未结 4 1934
野趣味
野趣味 2020-12-29 12:43

I am trying to follow the tutorial given in: https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html

相关标签:
4条回答
  • 2020-12-29 13:04

    In OpenCV 3.0.0-dev, you have to compile with the contrib repos and then it's in the bgsegm sub-module. I.e. just call cv2.bgsegm.createBackgroundSubtractorGMG()

    0 讨论(0)
  • 2020-12-29 13:15

    bgsegm was in contrib module of opencv, but after the update I am not sure.

    But still, if you have not built contrib module:

    pip install opencv-contrib-python
    

    Make sure no console is running that has imported cv2 while you execute your installing process. Run the cmd as Administration

    It worked for me.

    0 讨论(0)
  • 2020-12-29 13:23

    oh dear, that's another one of those stories ...

    with 2.4.6, you only can use BackgroundSubtractorMOG from python. (full stop)

    as of 2.4.8, it seems, the BackgroundSubtractorMOG2 problem got fixed, but the BackgroundSubtractorGMG is still missing.

    with both versions, you use a plain constructor to create one.

    in 3.0 (master), they changed the syntax, you now have to call 'createBackgroundSubtractorGMG', 'createBackgroundSubtractorMOG2' and such (that's what your tutorial might be refering to). but now you can use all 3 versions at least.

    so in any way, if you want to use BackgroundSubtractorMOG2 , you'll have to update to 2.4.8, if you need BackgroundSubtractorGMG, you'll need 3.0 (which is 'bleeding edge' in a way, but the new interface has the far better control over the params needed, imho).

    0 讨论(0)
  • 2020-12-29 13:28
    cv2.bgsegm.createBackgroundSubtractorGMG()
    cv2.createBackgroundSubtractorMOG2()
    cv2.bgsegm.createBackgroundSubtractorMOG(),
    

    **this worked for me **

    0 讨论(0)
提交回复
热议问题