View Single Post
  #2   Spotlight this post!  
Unread 07-22-2016, 09:03 AM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 298
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: 2 Cameras in Java

CameraServer.getInstance(), as the name implies, returns a singleton instance of CameraServer. That means server1 and server2 are the same in your code.

Here's how you might get both camera feeds into a single frame

Code:
// init
USBCamera cam0 = new USBCamera("cam0");
USBCamera cam1 = new USBCamera("cam1");
Image cam0Image = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0);
Image cam1Image = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0);
Image combinedImage = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0);

cam0.openCamera();
cam1.openCamera();
cam0.startCapture();
cam1.startCapture();

// on each iteration
cam0.getImage(cam0Image);
cam1.getImage(cam1Image);
GetImageSizeResult cam0Size = NIVision.imaqGetImageSize(cam0Image);
GetImageSizeResult cam1Size = NIVision.imaqGetImageSize(cam1Image);
NIVision.imaqCopyRect(combinedImage, cam0Image, new Rect(0, 0, cam0Size.width, cam0Size.height), new Point(0, 0));
NIVision.imaqCopyRect(combinedImage, cam1Image, new Rect(0, 0, cam1Size.width, cam1Size.height), new Point(cam0Size.width, 0));

CameraServer.getInstance().setImage(combinedImage);
Disclaimer: untested, but you get the idea
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote