简体   繁体   中英

Using OpenCV to connect to USB camera

For some reason, my script fails to recognize the USB camera connected (MU500), it does, however, recognize and display my other camera which is an analog converted to USB camera. The below script is a portion of the GUI that runs and displays the video capture.

    import cv

    camera = int(self.camera.GetValue())-1
    img_name = self.img_name.GetValue()+'.jpg'
    cap = cv2.VideoCapture(camera)

    while(cap.isOpened()):

        ret, frame = cap.read()
        cv2.imshow('Camera',frame)

        if cv2.waitKey(1) & 0xFF==ord('q'):
            cap.release()
            cv2.destroyAllWindows()
            break
        elif cv2.waitKey(1)== ord('s'):

            cv2.imwrite(filename=img_name, img=frame)
            cap.release()
            print("Image saved!")
            break

The user inputs '1' to access camera 1, or '2' for camera 2 and so on. I have tried having just MU500 connected and both connected. Neither recognize MU500. MU500 uses an AmScope driver and is listed as an imaging device in device manager.

Is there anyone who can help me?

You may try to install:

sudo apt-get install v4l-utils

and use:

v4l2-ctl --list-devices

to list all your devices and their properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM