Go to Post I'm always shocked when I see wiring having a bad hair day. - JaneYoung [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
  #8   Spotlight this post!  
Unread 08-03-2016, 16:18
BenBernard BenBernard is offline
Registered User
FRC #5687 (The Outliers)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Portland, ME
Posts: 37
BenBernard is an unknown quantity at this point
Re: Multiple USB Camera Switching Lag

Without having looked at any of your actual code (sorry, pressed for time) I can tell you that we encountered similar behavior and solved it by opening and initializing both USBCamera instances at the beginning, then passing one or the other in to our CustomCameraServer.startAutomaticCapture method.

We made a slight modification (available gratis on our github) which stops streaming on one camera, then starts it on the other. The delay seemed to be with initializing the cameras, not starting capture.

Code:
 
public synchronized void startAutomaticCapture(USBCamera camera) {
        if (camera==null) {
            return;
        }

        if (m_autoCaptureStarted) {
            m_camera.stopCapture();
            m_camera = camera;
            m_camera.startCapture();
            return;
        }
        m_autoCaptureStarted = true;
        m_camera = camera;

        m_camera.startCapture();

        Thread captureThread = new Thread(new Runnable() {
            @Override
            public void run() {
                capture();
            }
        });
        captureThread.setName("Camera Capture Thread");
        captureThread.start();
    }
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 08:27.

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