Using the Raspberry Pi Camera on Bullseye OS and OpenCV

Then the following code will allow you to grab a frame and show a frame in a window. Looking this sequence creates a live video preview on your Raspberry Pi Screen.