Me and my team have been having problems getting the CameraServer to work with a Lifecam; it consistently throws this error with code built and deployed on both Windows and Macintosh, as well as from a blank project with the default camera code and existing code:
CS: ERROR: USB Camera 0: ioctl VIDIOC_STREAMON failed: Input/output error (UsbCameraImpl.cpp:632)
Sometimes the error does not appear, but the console repeatedly says:
CS: USB Camera 0 Connecting to USB Camera on dev/video0
We pugged the cameras directly into our laptop to ensure they worked and gave output.
Additionally, when we ran our code, the camera registered on Shuffleboard, but still threw an error.
We tried the MJpeg Server, CameraServer.startAutomaticCapture(), and CameraServer.putVideo().
Where are you starting automatic capture? This error can be caused by putting startAutomaticCapture in an iterative method (it being called multiple times). It should be placed in a constructor.
We used the following code and the simple vision example (just CameraServer.startAutomaticCapture() in robotInit()):
package frc.robot.subsystems;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Point;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import edu.wpi.cscore.*;
import edu.wpi.first.cameraserver.CameraServer;
import frc.robot.Robot;
/**
* The camera on the robot.
*
* This is responsible for managing the camera and its output, including any
* processing which may be involved (in this case OpenCV).
*/
public class Camera extends SubsystemBase {
private UsbCamera camera;
private CvSink targetInput;
private CvSource targetOutput;
@Override
public void init(Robot robot) {
camera = CameraServer.getInstance().startAutomaticCapture();
}
@Override
String getSubsystemName() {
return "Camera";
}
}