capture one frame using beaglebone black ==> it does not work

1- i am using xcfe debian11.7
2-debian@BeagleBone:~$ ls /dev/video*
/dev/video0 /dev/video1
video0 is my webcam
3- sudo apt update
4- sudo apt install python3-pip
5- sudo apt install python3-opencv
6- sudo usermod -aG video debian
7- ls -l /dev/video*
8- python3 capture_webcam.py

import cv2

def capture_frame():
# Open the webcam for capturing frames
cap = cv2.VideoCapture(0) # 0 indicates the default camera (video0 in our case)

# Check if the camera opened successfully
if not cap.isOpened():
    print("Error: Unable to access the webcam.")
    return

# Capture a single frame
ret, frame = cap.read()

# Release the webcam
cap.release()

# Display the captured frame
cv2.imshow("Captured Frame", frame)
cv2.waitKey(0)
cv2.destroyAllWindows()

if name == “main”:
capture_frame()