0

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!

watersheep23
  • 339
  • 1
  • 3
  • 17
  • What is your camera model ? – Yunus Temurlenk Feb 15 '22 at 07:26
  • According to the output of ```lsusb```, I have the QinHeng Electronics HL-340 SUB-Serial adapter connected to my machine. Here is a link to the User's Manual of the camera: https://downloads.monoprice.com/files/manuals/35520_Manual_181228.pdf. – watersheep23 Feb 16 '22 at 00:40

1 Answers1

0

Might not solve this specific problem, but worth a shot. Try to open a cemera using imutils

from imutils import video  # pip install imutils
cam = video.VideoStream(src=port).start()
frame = cam.read()
gilad eini
  • 360
  • 2
  • 6