Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Refreshing SmartDashboard Simple Camera Feed (http://www.chiefdelphi.com/forums/showthread.php?t=133202)

MHSrobotics2853 20-01-2015 00:59

Refreshing SmartDashboard Simple Camera Feed
 
We want to run two cameras this year (for alignment purposes). Right now we're using the Axis M1011 and 206. We would like to turn off a camera when it's not needed to conserve bandwith. We couldn't find a function to turn it off and on. Is there anyway to do that?

We then tried to set the camera that's not in use to a terrible resolution (compression -> 100) after pressing a button on the joystick. However, the SmartDashboard doesn't automatically refresh the feed. We have to disconnect and reconnect for the new settings to take effect or close/reopen SmartDashboard.

Does anyone have a workaround for this? We program in C++ & use Windows.

Merfoo 20-01-2015 01:48

Re: Refreshing SmartDashboard Simple Camera Feed
 
I don't know if there is a function to turn off a camera but you can choose which image gets sent to the dashboard/smartdashboard (whichever you're using, doesn't really matter).

MHSrobotics2853 20-01-2015 02:28

Re: Refreshing SmartDashboard Simple Camera Feed
 
Quote:

Originally Posted by Merfoo (Post 1430868)
I don't know if there is a function to turn off a camera but you can choose which image gets sent to the dashboard/smartdashboard (whichever you're using, doesn't really matter).

How would we be able to do that through code? Is it a function of the SmartDashboard class?

We know how to delete and add widgets on SmartDashboard, but during competition, that would eat up a lot of time, especially if we need to switch angles quickly.

Greg McKaskle 20-01-2015 07:06

Re: Refreshing SmartDashboard Simple Camera Feed
 
The connection to the camera is an http session. In LV, if you close the TCP handle, the camera will stop sending images. I'm not sure how to do the equivalent in SD.

Greg McKaskle

Merfoo 21-01-2015 16:13

Re: Refreshing SmartDashboard Simple Camera Feed
 
The "Intermediate Vision" example project contains an example of getting an image from usb camera, modifying it, and then sending it to the dashboard. To have a system where you have multiple cameras and want to choose which img from which camera gets sent to the dashboard you'll need to do several things. The following code examples are in java but it should be similar in c++.

1) You need to create ids for each camera by supplying the camera name, the camera name shows up on the roborio interface ("roborio-TEAM.local/" where TEAM is your team number, "roborio-2853.local/" in your case)
Code:

// Get camera ids by supplying camera name ex 'cam0', found on roborio web interface
camCenter = NIVision.IMAQdxOpenCamera("cam0", NIVision.IMAQdxCameraControlMode.CameraControlModeController);
camRight = NIVision.IMAQdxOpenCamera("cam1", NIVision.IMAQdxCameraControlMode.CameraControlModeController);

2) You need to create an img variable where the img from the camera will be stored to and create a CameraServer that will send it to the dashboard
Code:

// Img that will contain camera img
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
// Server that we'll give the img to
server = CameraServer.getInstance();

3) Before getting imgs from a camera and sending it to the CameraServer you need to setup the camera for streaming and close the streaming of the previous camera
Code:

NIVision.IMAQdxStopAcquisition(prevCamId);
NIVision.IMAQdxConfigureGrab(newCamId);
NIVision.IMAQdxStartAcquisition(newCamId);

4) Now for the imgs from the camera to actually show up you need to get imgs from the camera and give them to the CameraServer
Code:

NIVision.IMAQdxGrab(curCamId, frame, 1);
server.setImage(frame);

Link to example java project: https://github.com/Merfoo/MultiCamera
If you have any questions feel free to ask :)


All times are GMT -5. The time now is 02:41.

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