项目:Sprocket
文件:CameraServers.java
public CameraServers(String... camNamesInput) {
cams=new USBCamera[camNamesInput.length];
camNames=camNamesInput;
m_quality = 50;
m_camera = null;
m_imageData = null;
m_imageDataPool = new arraydeque<>(3);
for (int i = 0; i < 3; i++) {
m_imageDataPool.addLast(ByteBuffer.allocateDirect(kMaxImageSize));
}
serverThread = new Thread(new Runnable() {
public void run() {
try {
serve();
} catch (IOException e) {
// do stuff here
} catch (InterruptedException e) {
// do stuff here
}
}
});
serverThread.setName("CameraServer Send Thread");
serverThread.start();
}
项目:Sprocket
文件:CameraServers.java
private synchronized void startbroadcast(USBCamera camera) {
if (m_autoCaptureStarted)
return;
m_autoCaptureStarted = true;
m_camera = camera;
m_camera.startCapture();
Thread captureThread = new Thread(new Runnable() {
@Override
public void run() {
capture();
}
});
captureThread.setName("Camera Capture Thread");
captureThread.start();
}
public synchronized void startAutomaticCapture(USBCamera camera) {
if (m_autoCaptureStarted)
return;
m_autoCaptureStarted = true;
m_camera = camera;
m_camera.startCapture();
Thread captureThread = new Thread(new Runnable() {
@Override
public void run() {
capture();
}
});
captureThread.setName("Camera Capture Thread");
captureThread.start();
}
项目:Robot_2016
文件:CameraServer2832.java
/**
* Start automatically capturing images to send to the dashboard.
*
* You should call this method to just see a camera Feed on the dashboard
* without doing any vision processing on the roboRIO. {@link #setimage}
* shouldn't be called after this is called.
*
* @param cameraName The name of the camera interface (e.g. "cam1")
*/
public void startAutomaticCapture(String cameraName) {
try {
USBCamera camera = new USBCamera(cameraName);
camera.openCamera();
startAutomaticCapture(camera);
} catch (VisionException ex) {
//DriverStation.reportError(
// "Error when starting the camera: " + cameraName + " " + ex.getMessage(),true);
}
}
项目:Robot_2016
文件:CameraServer2832.java
public synchronized void startAutomaticCapture(USBCamera... camera) {
if (m_camera.length == 0 || m_autoCaptureStarted)
return;
m_autoCaptureStarted = true;
m_camera = camera;
boolean hasFailed = false;
for (int i = 0; i < m_camera.length; i++)
{
try
{
m_camera[selectedCamera].startCapture();
hasFailed = false;
break; // If this is reached,}
catch (VisionException e)
{
hasFailed = true;
}
}
if (hasFailed)
return;
Thread captureThread = new Thread(new Runnable() {
@Override
public void run() {
capture();
}
});
captureThread.setName("Camera Capture Thread");
captureThread.start();
}
项目:2016-Robot-Final
文件:Robot.java
public void robotinit() {
// Create subsystems
drive = new Drive();
intake = new Intake();
arm = new Arm();
shooter = new Shooter();
hanger = new Hanger();
oi = new OI();
// Create motion profiles
crossLowBar = new Profile(AutoMap.crossLowBar);
reach = new Profile(AutoMap.reach);
toShoot = new Profile(AutoMap.toShoot);
toLowGoal = new Profile(AutoMap.toLowGoal);
// Pick an auto
chooser = new SendableChooser();
chooser.addDefault("Do nothing",new Donothing());
chooser.addobject("Low Bar",new LowBarRawtonomous());
chooser.addobject("Low Bar (profile)",new CrossLowBar(crossLowBar));
chooser.addobject("Reach",new Reach(reach));
chooser.addobject("Forward Rawto",new ForwardRawtonomous());
chooser.addobject("Backward Rawto",new BackwardRawtonomous());
chooser.addobject("Shoot",new AutoShoot());
SmartDashboard.putData("Auto mode",chooser);
// Start camera stream
camera = new USBCamera();
server = CameraServer.getInstance();
server.setQuality(40);
server.startAutomaticCapture(camera);
// Start compressor
compressor = new Compressor();
compressor.start();
navx = new AHRS(SPI.Port.kMXP);
}
项目:Sprocket
文件:CameraServers.java
/**
* Start automatically capturing images to send to the dashboard.
*
* You should call this method to just see a camera Feed on the dashboard
* without doing any vision processing on the roboRIO. {@link #setimage}
* shouldn't be called after this is called.
*
* @param cameraName The name of the camera interface (e.g. "cam1")
*/
private USBCamera startCamera(String cameraName) {
try {
USBCamera camera = new USBCamera(cameraName);
camera.openCamera();
//startAutomaticCapture(camera);
return camera;
} catch (VisionException ex) {
DriverStation.reportError(
"Error when starting the camera: " + cameraName + " " + ex.getMessage(),true);
}
return null;
}
项目:2016-Robot
文件:Robot.java
public void robotinit() {
// Create subsystems
drive = new Drive();
intake = new Intake();
arm = new Arm();
shooter = new Shooter();
hanger = new Hanger();
oi = new OI();
// Create motion profiles
crossLowBar = new Profile(AutoMap.crossLowBar);
reach = new Profile(AutoMap.reach);
toShoot = new Profile(AutoMap.toShoot);
toLowGoal = new Profile(AutoMap.toLowGoal);
// Pick an auto
chooser = new SendableChooser();
chooser.addDefault("Do nothing",chooser);
// Start camera stream
camera = new USBCamera();
server = CameraServer.getInstance();
server.setQuality(40);
server.startAutomaticCapture(camera);
// Start compressor
compressor = new Compressor();
compressor.start();
navx = new AHRS(SPI.Port.kMXP);
}
/**
* Start automatically capturing images to send to the dashboard.
*
* You should call this method to just see a camera Feed on the dashboard
* without doing any vision processing on the roboRIO. {@link #setimage}
* shouldn't be called after this is called.
*
* @param cameraName The name of the camera interface (e.g. "cam1")
*/
public void startAutomaticCapture(String cameraName) {
try {
USBCamera camera = new USBCamera(cameraName);
camera.openCamera();
startAutomaticCapture(camera);
} catch (VisionException ex) {
DriverStation.reportError(
"Error when starting the camera: " + cameraName + " " + ex.getMessage(),true);
}
}
项目:FRC-2016
文件:CameraController.java
public static void initCameras() {
if (init)
return;
bowCam = new USBCamera("cam0");
sternCam = new USBCamera("cam1");
//targetCam = new USBCamera("cam2");
init = true;
}
项目:turtleshell
文件:TurtwigDoubleVision.java
private TurtwigDoubleVision() {
try {
sendImage = NIVision.imaqCreateImage(ImageType.IMAGE_RGB,0);
cameras.add(new USBCamera("cam0"));
} catch (Exception e) {
TurtleLogger.critical("Camera Not found");
e.printstacktrace();
}
}
项目:Robot_2016
文件:CameraServer2832.java
/**
* Start automatically capturing images to send to the dashboard. You should
* call this method to just see a camera Feed on the dashboard without doing
* any vision processing on the roboRIO. {@link #setimage} shouldn't be called
* after this is called. This overload calles
* {@link #startAutomaticCapture(String)} with the default camera name
*/
public void startAutomaticCapture() {
startAutomaticCapture(USBCamera.kDefaultCameraName);
}
/**
* Start automatically capturing images to send to the dashboard. You should
* call this method to just see a camera Feed on the dashboard without doing
* any vision processing on the roboRIO. {@link #setimage} shouldn't be called
* after this is called. This overload calles
* {@link #startAutomaticCapture(String)} with the default camera name
*/
public void startAutomaticCapture() {
startAutomaticCapture(USBCamera.kDefaultCameraName);
}