Go to Post While we're on the topic of games... there have to be some people who'd be interested in a good round of FIRST ROBOTICS!!!!!!!!!!!!!!!!!!! :p :yikes: :D :rolleyes: - Leav [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 02-02-2017, 22:24
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 268
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: Delay in source switching and high latency for cameras

What camera models are you using and how much lighting do you have / what are your camera settings? With some testing with a HD-3000, FPS is 30 with a brightly lit scene, but can drop off to <10 fps given a dark scene as the camera goes into a low light mode. Setting the exposure controls to fixed rather than auto can fix these sorts of issues (open a web browser to http://roborio-449-frc.local:5800/ to get a simple settings gui to try things out).

The main reason you're seeing the delay in switching between cameras is because cscore automatically turns off the camera you're not using, so when you switch it needs to go through the entire connection process all over again. This is intentional to save CPU resources when there's no one connected to the camera stream, but there's a relatively easy workaround: create a CvSink, connect it to the camera, and enable it (it's not necessary to grab frames). This will cause the library to stay connected to the camera (because an enabled sink is always connected). E.g.:

Code:
public CvSink sink1;
public CvSink sink2;

...

sink1 = new CvSink("cam1cv");
sink1.setSource(cam1);
sink1.setEnabled(true);

sink2 = new CvSink("cam1cv");
sink2.setSource(cam2);
sink2.setEnabled(true);
Note you can use the CameraServer wrapper classes to get the other benefits of CameraServer (e.g. NetworkTables publishing), with code like the following rather than calling "new UsbCamera" explicitly.
Code:
cam1 = CameraServer.getInstance().startAutomaticCapture(0);
cam2 = CameraServer.getInstance().startAutomaticCapture(1);
server = CameraServer.getInstance().getServer();

// dummy CvSinks
sink1 = CameraServer.getInstance().getVideo(cam1);
sink1.setEnabled(true);
sink2 = CameraServer.getInstance().getVideo(cam2);
sink2.setEnabled(true);
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
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 15:31.

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