Go to Post The real world doesn't snap together easily. - Joe G. [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-03-2015, 08:04 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Dual Cameras?

Hmm... OK, in looking through the WPILib sources (C++), it appears that the camera server is hard-coded to camera 0. Not only that, but the NI vision system remembers which cameras were enumerated as "cam0" and "cam1". In general, that's not necessarily a problem, unless one of your cameras gets trashed and you try to substitute another. The new camera will be enumerated as "camx" where x is > 0. This will cause the cameraserver to fail because it's hardcoded to only work with cam0.

So, short of porting mjpegserver over to the roboRIO, does anyone have an approach for using dual USB cameras?

TIA,

Mike
  #2   Spotlight this post!  
Unread 02-03-2015, 09:44 PM
Adamz_'s Avatar
Adamz_ Adamz_ is offline
Who wants coffee?
AKA: Connor Adams
FRC #4519 (Kings Mechavaliers)
Team Role: Mentor
 
Join Date: May 2013
Rookie Year: 2013
Location: Oakville
Posts: 33
Adamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to behold
Re: Dual Cameras?

I'm going off of memory here because i don't have a roboRio to test with, but I'm fairly certain that within the Rio's web interface you can change the names of cameras to satisfy having the name cam0 or cam1.

Another way around this is with the cameraServer class, wich allows you to specify what camera you want to get the feed one.

For the example below, you would be receiving data from cam3 on the rio dashboard.
Code:
void CameraServer::StartAutomaticCapture (cam3)
If the above code doesn't make much sense i apologize, but I'm a java programmer.
__________________
2016 North Bay Regional Finalists
2016 Greater Toronto Central Regional Semi-Finalists
2015 Windsor Essex Great Lakes Regional Quarter-Finalists
2014 Windsor Essex Great Lakes Regional Semi-Finalists
2014 Waterloo Regional Quarter-finalists
2013 Waterloo Regional Highest Rookie Seed
2013 Waterloo Regional Rookie All Star Recipient

Last edited by Adamz_ : 02-03-2015 at 11:34 PM. Reason: wrong link in hyperlink
  #3   Spotlight this post!  
Unread 02-03-2015, 10:35 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Dual Cameras?

Quote:
Originally Posted by Adamz_ View Post
I'm going off of memory here because i don't have a roboRio to test with, but I'm fairly certain that within the Rio's web interface you can change the names of cameras to satisfy having the name cam0 or cam1.

Another way around this is with the cameraServer class, wich allows you to specify what camera you want to get the feed one.

For the example below, you would be receiving data from cam3 on the rio dashboard.
Code:
void CameraServer::StartAutomaticCapture (cam3)
If the above code doesn't make much sense i apologize, but I'm a java programmer.
Thanks for the suggestion, but we already tried this. The camera server code does not have a stop method and trying to use a camera other than 0 results in lots of errors being displayed in the messages windows. In particular, failures in line 33 of the USBCamera class related to setting the jpeg compression ratio.

It would be nice if you could:

If (button1) {
CameraServer::GetInstance()->StartAutomaticCapture("cam0");
}
if (button2) {
CameraServer::GetInstance()->StartAutomaticCapture("cam1");
}

But, that fails miserably. This is due to several reasons. First, the StartAutomaticCapture ends up creating threads, opening sockets etc. for which there is no clean shutdown method in the class. Second, even if there were a clean shutdown method, there is an m_camera member in the class that is hard coded to camera 0.

So, there is no way to clean up if you shut could shut the class down. And, if you tried to force it in Linux by killing the thread manually, this will undoubtedly come back to haunt you toward the end of the match because the thread probably has resources tied up.

So, does anyone have any other ideas?

TIA,

Mike
  #4   Spotlight this post!  
Unread 02-04-2015, 04:10 PM
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: Dual Cameras?

The Intermediate Vision example project shows how to get an image from a camera and then sending it to the dashboard. So what you could do is have multiple camera objects and then choose which camera to get the image from and then send that image to the dashboard.
  #5   Spotlight this post!  
Unread 02-04-2015, 06:16 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Dual Cameras?

Quote:
Originally Posted by Merfoo View Post
The Intermediate Vision example project shows how to get an image from a camera and then sending it to the dashboard. So what you could do is have multiple camera objects and then choose which camera to get the image from and then send that image to the dashboard.
I'll take a look at that sample.

Thanks,

Mike
  #6   Spotlight this post!  
Unread 02-07-2015, 09:30 AM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Dual Cameras?

Fixed! Thanks to the suggestion from the previous post, I've got two cameras working with C++. It's a bit klugey, but the NI code really isn't built to run more than one camera at a time. I'm cleaning the code up today and I'll post a copy for those who are interested.

Mike
  #7   Spotlight this post!  
Unread 02-08-2015, 11:41 PM
vps vps is offline
Registered User
FRC #3021 (The Agency)
Team Role: Programmer
 
Join Date: Mar 2013
Rookie Year: 2011
Location: United States
Posts: 30
vps is an unknown quantity at this point
Re: Dual Cameras?

Can you please post/message me a copy? I've been unsuccessful doing that for a while.
  #8   Spotlight this post!  
Unread 02-10-2015, 08:41 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Dual Cameras?

Here is the code for dual cameras running on the RoboRio. The code is written in C/C++, but it should be readily adaptable to Java. The zip is in the form of an Eclipse project and should be able to be imported directly into Eclipse. This should be extensible to more than 2 cameras by modifying the teleop loop, startCamera and stopCamera code to handle the extra cameras. We hope this helps someone out there. If you've got any questions, feel free to ask.

HTH,

Mike
Attached Files
File Type: zip 2USBCams.zip (2.18 MB, 105 views)
  #9   Spotlight this post!  
Unread 02-11-2015, 12:59 AM
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: Dual Cameras?

An example of this in Java can also be found here:

https://github.com/Merfoo/MultiCamera
  #10   Spotlight this post!  
Unread 02-17-2015, 05:04 PM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Dual Cameras? -- Updated C++ Class Code

Greetings!

I've cleaned up the dual camera code and created a class ala the Java example that was posted earlier. Essentially, add the CameraFeeds.cpp and CameraFeeds.h to your project and then instantiate as it is done in the robot.cpp example. I've included the class in a working Mecanum example just so people can see the ability to drive and the dual cameras at the same time.

Enjoy,

Mike
Attached Files
File Type: zip 2USBCamsMecanum.zip (2.58 MB, 67 views)
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 03:37 AM.

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