destroyAllWindows()无法使用

问题遇到的现象和发生背景

destroyAllWindows()函数无法正常使用

用代码块功能插入代码,请勿粘贴截图
        # 打开摄像头并进行人脸录入
        cap = cv2.VideoCapture(0)
        # 中间的部分省略了
        cap.destroyAllWindows()
运行结果及报错内容

报错结果:AttributeError: 'cv2.VideoCapture' object has no attribute 'destroyAllWindows'

我的解答思路和尝试过的方法

网上都说拼写错了,但我的不是这个问题,求指教

destroyAllWindows是cv2的函数,不是cv2.VideoCapture类的方法。遍历dir(cap)可以查看cap实例的所有属性和方法。

import cv2
cap = cv2.VideoCapture(0)
for item in dir(cap):
    print(item)

    
__class__
__delattr__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__module__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__sizeof__
__str__
__subclasshook__
get
getBackendName
getExceptionMode
grab
isOpened
open
read
release
retrieve
set
setExceptionMode