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

Question:

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!!

Asked By: Bozhidar Botev

||

Answers:

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 !!)

Answered By: berak
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.