Global /tmp/pip-req-build-plozjof_/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can't open camera by index

I am trying to get input from camera device using “opencv-contrib-python-headless” in my requirements.txt:
cv2.VideoCapture(x),
provided 4 values for x : 0, 1, 2, -1
Nothing seems to be working. Got these errors for these 4 values.

[ WARN:1] global /tmp/pip-req-build-plozjof_/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can’t open camera by index
[ WARN:2] global /tmp/pip-req-build-plozjof_/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video1): can’t open camera by index
[ WARN:3] global /tmp/pip-req-build-plozjof_/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video2): can’t open camera by index
[ WARN:4] global /tmp/pip-req-build-plozjof_/opencv/modules/videoio/src/cap_v4l.cpp (880) open VIDEOIO(V4L2): can’t find camera device

“can’t find camera device” is for the value “-1”.