OpenCV can't find camera device in streamlit app

I was trying to make an ArUco detection app using opencv in Streamlit [Link]. However, the camera was not detected after deploying, although it worked perfectly fine in localhost.
The following error appeared:

[ WARN:0@0.089] global cap_v4l.cpp:997 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:0@0.090] global obsensor_uvc_stream_channel.cpp:159 getStreamChannelGroup Camera index out of range

The code I used was:

def init_camera():
return cv.VideoCapture(0)

cap = init_camera()

and can be found at GitHub - benab04/ArUco-Detection, along with the requirements.txt file in the streamlit_app folder.

I have used Windows 11 to code the entire app, not Ubuntu or Linux

You cannot use cv.VideoCapture() if the streamlit app runs on any hosted environment. This is a basic misconception about how streamlit works. Search for opencv here and you will find plenty of threads. It is just luck that it works on localhost.