why cv2 has no attribute destroyAllWindows?

I trying to write a program for face recognition using opencv. This is the code in a file called facerec.py,

#!/usr/bin/env python

import cv2
import face_recognition
import os
import numpy as np
from datetime import datetime
import pickle
import re

def MainFunc():

    path = './student_images' #specify the path to the directory containing student images
    images = []
    className = []
    usnNum = []

    mylist = os.listdir(path) #get a list of image files in the specified directory

    #loop through each image file in the directory
    for cl in mylist:
        curImg = cv2.imread(f'{path}/{cl}') #read the image file
        images.append(curImg)
        Fname_ext = os.path.splitext(cl)[0] #extract the class name (student's name) from the file name without the extension
        Fname = re.split('_', Fname_ext)
        className.append(Fname[0]) #append the Name
        usnNum.append(Fname[1]) #append the USN

        #className.append(os.path.splitext(cl)[0]) #extract the class name (student's name) from the file name without the extension

    #define a function to find face encodings from a list of images
    def findEncodings(images):
        encodeList = []
        for img in images:
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) #convert the images from BGR format to RGB format (required by face_recognition)
            encoded_face = face_recognition.face_encodings(img)[0] #encode the face in the image
            encodeList.append(encoded_face)
        return encodeList

    encoded_face_train = findEncodings(images) #get the face encodings for the known student images

    #define a function to mark attendance
    def markAttendance(name,usn):
        with open('Attendance.csv', 'r+') as f: #open the attendance csv file in the read and write mode
            myDataList = f.readlines()
            nameList = []

            for line in myDataList: #extract existing names from the csv file
                entry = line.split(',')
                nameList.append(entry[0])

            if name not in nameList: #if the name is not in the csv file, add a new entry with the current time and date
                now = datetime.now()
                time = now.strftime('%I:%M:%S %p')
                date = now.strftime('%d-%B-%Y')
                f.writelines(f'n{name}, {usn}, {time}, {date}')

    cap = cv2.VideoCapture(0) #open the webcam (camera)

    while True:
        success, img = cap.read() #capture a frame from the webcam
        imgS = cv2.resize(img, (0,0), None, 0.25, 0.25) #resize the captured frame to 1/4 of its original size for faster processing
        imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB) #covert the resized frame from bgr to rgb format
        faces_in_frame = face_recognition.face_locations(imgS) #detect faces in the resized frame
        encoded_faces = face_recognition.face_encodings(imgS, faces_in_frame) #encode the detected faces

        for encoded_face, faceloc in zip(encoded_faces, faces_in_frame): #loop through each detected face in the frame
            matches = face_recognition.compare_faces(encoded_face_train, encoded_face) #compare the detected face with known faces
            faceDist = face_recognition.face_distance(encoded_face_train, encoded_face) #calculate the face distance to find the best match
            matchIndex = np.argmin(faceDist)

            if matches[matchIndex]: #if a match is found, mark attendance and display the name
                name = className[matchIndex].upper().lower()
                usn = usnNum[matchIndex].upper().lower()
                y1, x2, y2, x1 = faceloc
                y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4 #scale coordinates back to original size
                cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 2) #draw a rectangle around the detected face
                cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (255, 0, 0), cv2.FILLED) #draw a filled rectangle for displaying the name
                cv2.putText(img, name, (x1 + 6, y2 - 5), cv2.FONT_HERSHEY_COMPLEX, 1, (255,255,255), 2) #display the name on the frame
                markAttendance(name,usn) #call the markAttendacne function to record attendance

        cv2.imshow('webcam', img) #display the frame with detected faces and names

        if cv2.waitKey(1) & 0xFF == ord('q'):
            print("Q hit, closing...")
            break

        cap.release()
        cv2.destoryAllWindows()

if __name__ == '__main__':
    MainFunc()

The error that i am getting is,

Traceback (most recent call last):
  File "facerec.py", line 97, in <module>
    MainFunc()
  File "facerec.py", line 94, in MainFunc
    cv2.destoryAllWindows()
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'cv2' has no attribute 'destoryAllWindows'

I am running this in a virtual environment and the packages installed are,

Package                 Version
----------------------- ---------
click                   8.1.7
dlib                    19.24.4
face-recognition        1.3.0
face_recognition_models 0.3.0
greenlet                3.0.3
msgpack                 1.0.8
numpy                   1.26.4
opencv-python           4.10.0.82
packaging               24.1
pillow                  10.3.0
pip                     24.0
setuptools              70.0.0

This is what I have tried to do, since I couldn’t look up much about it on google, I commented the cv2.destroyAllWindows() but now there is a error like,

Traceback (most recent call last):
  File "facerec.py", line 102, in <module>
    MainFunc()
  File "facerec.py", line 67, in MainFunc
    imgS = cv2.resize(img, (0,0), None, 0.25, 0.25) #resize the captured frame to 1/4 of its original size for faster processing
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgproc/src/resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

I tried following the answers from the previously asked question without any success. I am running the program on Linux, the code was working well before a reboot, I can’t figure out what changed. Any help is much appreciated.

New contributor

dumbN00b is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật