![]() |
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 |
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) |
Re: Dual Cameras?
Quote:
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 |
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.
|
Re: Dual Cameras?
Quote:
Thanks, Mike |
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 |
Re: Dual Cameras?
Can you please post/message me a copy? I've been unsuccessful doing that for a while.
|
Re: Dual Cameras?
1 Attachment(s)
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 |
Re: Dual Cameras?
|
Re: Dual Cameras? -- Updated C++ Class Code
1 Attachment(s)
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 |
| All times are GMT -5. The time now is 03:37 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi