2022-03-25 08:34:25 -06:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
package frc4388.robot.subsystems;
|
|
|
|
|
|
|
|
|
|
import edu.wpi.first.cscore.*;
|
2022-03-25 09:15:02 -06:00
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
2022-03-25 08:34:25 -06:00
|
|
|
import edu.wpi.first.cameraserver.CameraServer;
|
|
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|
|
|
|
|
|
|
|
|
public class Camera extends SubsystemBase {
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new Camera.
|
|
|
|
|
* Makes a Camera and sends the stream to a CameraServer, to be viewed in Shuffle Board.
|
|
|
|
|
* @param name Name of the Camera in Shuffle Board.
|
|
|
|
|
* @param id USB Id of the Camera.
|
|
|
|
|
* @param width Resolution width.
|
|
|
|
|
* @param height Resolution height.
|
|
|
|
|
* @param brightness Percent brightness of the stream.
|
|
|
|
|
*/
|
2022-03-25 09:15:02 -06:00
|
|
|
|
|
|
|
|
public UsbCamera test;
|
|
|
|
|
|
2022-03-25 08:34:25 -06:00
|
|
|
public Camera(String name, int id, int width, int height, int brightness) {
|
|
|
|
|
try{
|
2022-03-25 09:15:02 -06:00
|
|
|
UsbCamera cam = CameraServer.startAutomaticCapture();//new UsbCamera(name, id);
|
2022-03-25 08:34:25 -06:00
|
|
|
cam.setResolution(width, height);
|
|
|
|
|
cam.setBrightness(brightness);
|
|
|
|
|
cam.setFPS(10);
|
2022-03-25 09:15:02 -06:00
|
|
|
SmartDashboard.putBoolean("cam enabled", cam.isEnabled());
|
|
|
|
|
SmartDashboard.putBoolean("cam connected", cam.isConnected());
|
|
|
|
|
// VideoSource camera = cam;
|
|
|
|
|
// CameraServer.addCamera(camera);
|
|
|
|
|
// CameraServer.startAutomaticCapture(camera);
|
2022-03-25 08:34:25 -06:00
|
|
|
}
|
|
|
|
|
catch(Exception e) {
|
|
|
|
|
System.err.println("Camera broken, pls nerf");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void periodic() {}
|
|
|
|
|
}
|