Go to Post Don't test your autonomous on the comp field. There's a practice field for a reason. - DampRobot [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 16-01-2016, 18:05
kmodos kmodos is offline
Registered User
AKA: Alex
FRC #1126 (SparX)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: New York
Posts: 57
kmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to behold
Post [Snippet] Using 2+ Cameras with minimal bandwidth usage

After messing around with cameras today, I was able to figure out how to use multiple cameras while only using the bandwidth of one. To do such, you simply switch between which feed you are sending back to the driver station with the touch of a button. See the code down below to see how to do this.

Variables needed:
Code:
int currSession;
int sessionfront;
int sessionback;
Image frame;
Init code:
Code:
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);

sessionfront = NIVision.IMAQdxOpenCamera("cam1", NIVision.IMAQdxCameraControlMode.CameraControlModeController);
        
sessionback = NIVision.IMAQdxOpenCamera("cam2", NIVision.IMAQdxCameraControlMode.CameraControlModeController);

currSession = sessionfront;

NIVision.IMAQdxConfigureGrab(currSession);
Switch between views:
Code:
if(/*button pressing code*/){
        if(currSession == sessionfront){
       		  NIVision.IMAQdxStopAcquisition(currSession);
 		  currSession = sessionback;
	          NIVision.IMAQdxConfigureGrab(currSession);
 	} else if(currSession == sessionback){
      		  NIVision.IMAQdxStopAcquisition(currSession);
       		  currSession = sessionfront;
       		  NIVision.IMAQdxConfigureGrab(currSession);
        }
}
Sending the images to the DS:
Code:
NIVision.IMAQdxGrab(currSession, frame, 1);
CameraServer.getInstance().setImage(frame);
This code can easily be extended to include more than two cameras, if you wish. If anyone needs help implementing this, feel free to PM me/post below.

Last edited by kmodos : 16-01-2016 at 18:07. Reason: Spacing
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi