Raspberry Pi does not recognize camera

We are having trouble getting our Raspberry Pi 4 to recognize a webcam. We are running the FRC image and can connect to the web interface. The status seem normal.

We are using a Lifecam and the web interface sees it and lets us add it:

We are connected to a laptop with the Pi in server mode and set to writable. When we try to open a stream from the vision settings page, we get the site can’t be reached error. We tried turning off the firewalls and LAN proxy.
image

We know the camera works because we get an image when plugged into the laptop. Also tried a 2nd Lifecam with the same results. We also tried turning off the driver for the laptop’s built in camera.

We tried uploading a simple python code

from cscore import CameraServer, VideoSource, UsbCamera, MjpegServer

import cv2

import numpy as np

cs = CameraServer.getInstance()

cvSink = cs.getVideo()

cs.enableLogging()

camera = cs.startAutomaticCapture()

camera.setResolution(320, 240)

outputStream = cs.putVideo(“Name”, 320, 240)

while True:

time, img = cvSink.grabFrame(img)

if time == 0:

    # Send the output the error.

    outputStream.notifyError(cvSink.getError());
    continue

outputStream.putFrame(img)<

but get the error:


Not sure why we get the “no camera available” available.

One more note - the blue LED on the camera turns on briefly when the Pi is started or restarted, but turns off quickly after.

Anyone have a suggestion?

The traceback is pointing to your issue–cs.getVideo() is being called before any cameras are set up, so there’s nothing for it to return. You need to move that line after cs.startAutomaticCapture(). From the documentation for getVideo():

If there are no arguments, then this will retrieve access to the primary camera. No arguments will fail if a camera feed has not already been added via startAutomaticCapture or addCamera

The camera stream page only works if the vision application is running–since the application is exiting with an error, the stream page won’t work.

Thank you - that worked !