‘builtin_function_or_method’ object has no attribute ‘apply’ cv2

I’m trying to create a mask but get the error when i run my code I am using visual Studio

Here is my code

import cv2
import numpy as np

cap = cv2.VideoCapture('file_name.mp4')

object_detector = cv2.createBackgroundSubtractorMOG2


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

    mask = object_detector.apply(frame)


    cv2.imshow('Cam Footage' , frame)
    cv2.imshow('Mask', mask)

    key = cv2.waitKey(30)
    if key == 27:
        break

cap.release()
cv2.destroyAllWindows()

Answer

change

cv2.createBackgroundSubtractorMOG2

with this

cv2.createBackgroundSubtractorMOG2()