Skip to content

Instantly share code, notes, and snippets.

@TechplexEngineer
Created July 16, 2016 12:20
Show Gist options
  • Select an option

  • Save TechplexEngineer/bbae780a554a1ee63057e18bf50f0425 to your computer and use it in GitHub Desktop.

Select an option

Save TechplexEngineer/bbae780a554a1ee63057e18bf50f0425 to your computer and use it in GitHub Desktop.
WPI Library USB Camera using a separate thread.
try {
new Thread(new CamThread()).start();
} catch(Exception ex) {
ex.printStackTrace();
}
//Put this in the file as a nested class
class CamThread implements Runnable {
@Override
public void run() {
USBCamera cam = new USBCamera("cam0");
Timer.delay(2);
Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
NIVision.RGBValue color = new RGBValue(0,255,0,255);
cam.setExposureManual(1);
cam.setFPS(6);
cam.setBrightness(50);
cam.startCapture();
while (true)
{
cam.getImage(frame);
CameraServer.getInstance().setImage(frame);
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment