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

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.")

# Capture a single frame
ret, frame =

# Release the webcam

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

if name == “main”: