|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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; 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);
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);
}
}
Code:
NIVision.IMAQdxGrab(currSession, frame, 1); CameraServer.getInstance().setImage(frame); Last edited by kmodos : 16-01-2016 at 18:07. Reason: Spacing |
|
#2
|
|||
|
|||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
When I put this in my code and deployed it to the robot several errors showed up and the dashboard indicated there was no code.
Where did you put all of these pieces of code in your project? |
|
#3
|
||||
|
||||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
kmodos: thank you very much. works perfectly for us.
has anyone figured out how to open both cameras at once? we would like to open both camera, grab a frame from each, lay them down side by side in a double size frame, and send *that* to the DS. The problem is that IMAQdxConfigureGrab throws an exception if you already have called it with*out* an intervening MAQdxStopAcquisition. Last edited by fovea1959 : 21-01-2016 at 12:35. Reason: "with" is not the same as "without" |
|
#4
|
|||
|
|||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
Quote:
Quote:
I might look into doing something like this. I have to talk with our drivers to see if this would be something that they want. If I get it working I will post it publicly. |
|
#5
|
||||
|
||||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
Worked like a charm, thanks! For anyone who's having trouble, make sure that all other camera code is removed. We accidentally left some in at first, and the code didn't work correctly.
|
|
#6
|
|||
|
|||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
Quote:
How you mash the two images together I don't know as I have basically zero experience with the NIVision libs. But, roll your own CameraServer, solve the issue of mashing images together into a single JPEG and there you go. |
|
#7
|
||||
|
||||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
Awesome code, this snippet will surely be helpful in the future. Thanks for sharing.
|
|
#8
|
|||
|
|||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
When I use this code my cameras seem to lag, does anyone have complete code that I can use as reference?
|
|
#9
|
|||
|
|||
|
Re: [Snippet] Using 2+ Cameras with minimal bandwidth usage
Does the lag occur when you switch between the two? Switching will always lag a bit as well as all feeds will lag a tiny bit. Try to lower the quality of the returned image or lower the resolution.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|