我一直在尝试新的Open CV版本,Open CV 3.0中的背景减法。我在Open CV 3.0和python 2.7中练习BackgroundSubtractorGMG。我尝试在这个BackgroundSubtractorGMG代码。错误提示:
文件"background.py",第10行,在fgbg = cv2.createBackgroundSubtractorGMG() AttributeError: 'module'对象没有属性'createBackgroundSubtractorGMG'
如何解决这个错误?感谢您的关注和帮助,谢谢:-)
一旦你构建了opencv和opencv_contrib repo:
>>> help(cv2.bgsegm)
Help on module cv2.bgsegm in cv2:
NAME
cv2.bgsegm
FILE
(built-in)
FUNCTIONS
createBackgroundSubtractorGMG(...)
createBackgroundSubtractorGMG([, initializationFrames[, decisionThreshol
d]]) -> retval
createBackgroundSubtractorMOG(...)
createBackgroundSubtractorMOG([, history[, nmixtures[, backgroundRatio[,
noiseSigma]]]]) -> retval
换句话说,使用:
gmg = cv2.bgsegm.createBackgroundSubtractorGMG()