Go to Post Giving POWER and CHOICE to the people is the best route. - Franchesca [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
  #2   Spotlight this post!  
Unread 24-01-2017, 22:39
dmelcer9 dmelcer9 is offline
Registered User
AKA: Daniel
FRC #0810 (Mechanical Bulls)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2012
Location: Smithtown
Posts: 51
dmelcer9 is an unknown quantity at this point
Re: Switching Camera Views

You can do something like this (edited from the screensteps page):

Code:
public void robotInit() {
            new Thread(() -> {
                UsbCamera camera1 = CameraServer.getInstance().startAutomaticCapture(0);
                camera1.setResolution(640, 480);
                UsbCamera camera2 = CameraServer.getInstance().startAutomaticCapture(1);
                camera2.setResolution(640, 480);
                
                CvSink cvSink1 = CameraServer.getInstance().getVideo(camera1);
                CvSink cvSink2 = CameraServer.getInstance().getVideo(camera2);
                CvSource outputStream = CameraServer.getInstance().putVideo("Switcher", 640, 480);
                
                Mat image = new Mat();
                
                while(!Thread.interrupted()) {
                    if(/*switcher button logic*/){
                      cvSink1.grabFrame(image);
                    } else{
                      cvSink2.grabFrame(image);
                    }
                    
                    outputStream.putFrame(image);
                }
            }).start();
    }
I'm tired, so this is all I can think of now. The code may not be entirely right, but the general idea should work. There probably is a much better/simpler/more efficient way that I have no clue about.

Last edited by dmelcer9 : 24-01-2017 at 22:40. Reason: Code
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 13:15.

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