Go to Post No. This is CD, take the threads and their topics seriously. - pwnageNick [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-01-2015, 00:59
MHSrobotics2853's Avatar
MHSrobotics2853 MHSrobotics2853 is offline
Mililani Robotics
FRC #2853 (Trobobots)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Mililani, HI 96789
Posts: 47
MHSrobotics2853 is just really niceMHSrobotics2853 is just really niceMHSrobotics2853 is just really niceMHSrobotics2853 is just really niceMHSrobotics2853 is just really nice
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.

Last edited by MHSrobotics2853 : 20-01-2015 at 01:01.
  #2   Spotlight this post!  
Unread 20-01-2015, 01:48
Merfoo's Avatar
Merfoo Merfoo is offline
Registered User
FRC #0955 (CV Robotics)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: America
Posts: 48
Merfoo is an unknown quantity at this point
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).
  #3   Spotlight this post!  
Unread 20-01-2015, 02:28
MHSrobotics2853's Avatar
MHSrobotics2853 MHSrobotics2853 is offline
Mililani Robotics
FRC #2853 (Trobobots)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Mililani, HI 96789
Posts: 47
MHSrobotics2853 is just really niceMHSrobotics2853 is just really niceMHSrobotics2853 is just really niceMHSrobotics2853 is just really niceMHSrobotics2853 is just really nice
Re: Refreshing SmartDashboard Simple Camera Feed

Quote:
Originally Posted by Merfoo View Post
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.
  #4   Spotlight this post!  
Unread 20-01-2015, 07:06
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
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
  #5   Spotlight this post!  
Unread 21-01-2015, 16:13
Merfoo's Avatar
Merfoo Merfoo is offline
Registered User
FRC #0955 (CV Robotics)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: America
Posts: 48
Merfoo is an unknown quantity at this point
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
Closed Thread


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 02:41.

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