Home > database >  AttributeError: 'builtin_function_or_method' object has no attribute 'apply'
AttributeError: 'builtin_function_or_method' object has no attribute 'apply'

Time:09-11

cv2 Problem.. I was watching not that old of a tutorial about object tracking and stumbled in this error

AttributeError: 'builtin_function_or_method' object has no attribute 'apply'

This is the code around the issue.

object_detector = cv2.createBackgroundSubtractorMOG2

while True:
    ret, frame = cap.read()

    mask = object_detector.apply(frame)

    cv2.imshow("Frame", frame)
    cv2.imshow("Mask", mask)

In The tutorial the guy did the exact same thing!!

CodePudding user response:

you did not create the object_detector properly, it has to be:

object_detector = cv2.createBackgroundSubtractorMOG2() # BRACES !!!

you only made a copy of the create() function, not invoke it)

(also, rather use opencv's tutorials for this !!)

  • Related