I want to switch which camera is the main one in code. I have 3 cameras at all times on the smart dashboard but one is bigger than the other two. Is there a way in my c++ code that I can change which one is the main camera?
In smart dashboard, you should be able to set it to editable. Then, you can change the size of the camera windows.
I have seen about 28,964 differently defined ways on CD, but none that definitively work in C++.
I don’t want gee whiz programming wizardry. I’m looking for (and I think others are as well) documented sample code that successfully and SIMPLY implements camera switching of 2+ cameras in C++ and doesn’t require a degree in Computer Science to understand.
We’re not processing vision samples. We’re not trying to discern a retroreflective needle in a haystack of mayhem. We just want our dashboard to switch between 2+ cams on demand with the press of a button.
Is ANYONE out there bold and daring enough to take on this challenge and share what they KNOW works with the LATEST 2017 software? The undying gratitude of the entire FRC C++ programming community is there for the taking. Who will rise to the occasion?
Yes but that’s not what i want. I want to click a controller button and the main camera be changed so in the middle of a match i can easily switch between my 3 camera feeds.
Travis,
You will need to do some socket coding. More or less you need to create a client/server approach.
Check out this:
http://www.linuxhowtos.org/C_C++/socket.htm
You need to pass a single key stroke to whatever device that has the cameras. From there the device gets the code and switches the camera.
While we didn’t do this. We combined all of our camera feeds into a single feed to the driver station. Basically it displays all the cameras into a single image, each image side by side. No need to switch. And the feed is in nearly real time (a couple milliseconds behind and is probably due to the framerate).
K Murphy
Hey Robodragons. I found this earlier today. It’s late for my team since our regional was this past weekend, but it might not be too late for yours. We haven’t tested it since I just found it today.
https://www.chiefdelphi.com/forums/showthread.php?threadid=156518
#include “WPILib.h”
#include “cscore.h”
class Robot: public frc::SampleRobot {
cs::UsbCamera camera1;
cs::UsbCamera camera2;
cs::VideoSink server;
frc::Joystick joy { 0 };
public:
Robot() {
camera1 = CameraServer::GetInstance()->StartAutomaticCapture(0);
camera2 = CameraServer::GetInstance()->StartAutomaticCapture(1);
server = CameraServer::GetInstance()->GetServer();
}
void OperatorControl() {
while (IsOperatorControl() && IsEnabled()) {
if (joy.GetRawButton(1)) {
server.SetSource(camera2);
if (!joy.GetRawButton(1)) {
server.SetSource(camera1);
}
frc::Wait(0.005);
}
}
}
};
START_ROBOT_CLASS(Robot)
Anyone have any enlightenment for camera switching in C++ in 2018? Any solutions baked-in to wpilib?
Oh yeah, there’s also THIS thread - https://www.chiefdelphi.com/forums/showthread.php?threadid=156518.
We never did get switching working last year - just used a single camera. Still looking for ONE SWITCHING SOLUTION TO RULE THEM ALL. I think we were hoping for a solution that switched cameras between a single higher-res stream instead of switching between 2 separate, constantly-open, lower-res streams.
The main change in 2018 is the Linux kernel has been upgraded in such a way that for most use cases you shouldn’t run into USB bandwidth limitations, and therefore you should be able to keep two high resolution connections open simultaneously. So my reply in that thread (2) is the right way to do things. I’m not sure what you mean by the “ONE SWITCHING SOLUTION TO RULE THEM ALL”. I can’t really make it much easier in code than what I have in my response to that thread. If there’s an issue you’re running into or something you’re confused about with how that example code works, I’m happy to help.
The example was straightforward; however, I believe we still had trouble getting code to run when attempting to implement and had bigger fish to fry. We will probably revisit the code this year.
Good to know about the 2018 updates.