I am getting the warning [ WARN:0@0.037] global /io/opencv/modules/videoio/src/cap_v4l.cpp (889) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
when running the following code in my Ubuntu VM in VirtualBox:
import asyncio
import platform
import subprocess
import cv2
if platform.system() == 'Windows':
import winrt.windows.devices.enumeration as windows_devices
VIDEO_DEVICES = 4
class Camera:
def __init__(self):
self.cameras = []
def get_camera_indexes(self):
index = 0
camera_indexes = []
max_numbers_of_cameras_to_check = 10
while max_numbers_of_cameras_to_check > 0:
capture = cv2.VideoCapture(index)
if capture.read()[0]:
camera_indexes.append(index)
capture.release()
index += 1
max_numbers_of_cameras_to_check -= 1
return camera_indexes
camera = Camera()
print(camera.get_camera_indexes())
I have tried everything listed in this question: OpenCv error can't open camera through video capture, and still am having no luck getting rid of the warning. Any other ideas? Thanks!