Created
July 16, 2016 12:20
-
-
Save TechplexEngineer/bbae780a554a1ee63057e18bf50f0425 to your computer and use it in GitHub Desktop.
WPI Library USB Camera using a separate thread.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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