How to declare a camera in visual studio with java frc

I put a code but a warning appeared, this warning was “the method getinstance() from the type CameraServer is deprecated

1 Like
Thread visionThread = new Thread(() -> {
		System.out.println("In thread");
		UsbCamera camera = new UsbCamera("Microsoft Lifecam", "/dev/video0");
		camera.setResolution(160, 120);
		CvSink cvSink = CameraServer.getInstance().getVideo();
		CvSource outputStream = CameraServer.getInstance().putVideo("UsbCamera", 160, 120);

		Mat mat = new Mat();

		while (!Thread.interrupted()) {
			if (cvSink.grabFrame(mat) == 0) {
			// Core.flip(mat,mat,Core.ROTATE_180);
			Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY);

This sounds like a duplicate of Warning stting up a camera in a robot (java) to me

Can you post your code? It might be helpful for people to see.

change your camera server import to

import edu.wpi.first.cameraserver.CameraServer

1 Like

sorry if it isn’t clear enough

I meant take a screenshot of your code. So we can see the problem.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.