Skip to content

Commit

Permalink
Fix ordering between CameraServer.getInstance and UsbCamera creation (#…
Browse files Browse the repository at this point in the history
…69)

If the CameraServer instance is started after the UsbCamer is created, it
never gets the source created event to actually build the NetworkTable table.
  • Loading branch information
PeterJohnson authored Jan 14, 2019
1 parent 64b9491 commit 08163c0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deps/examples/cpp-multiCameraServer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ bool ReadConfig() {
cs::UsbCamera StartCamera(const CameraConfig& config) {
wpi::outs() << "Starting camera '" << config.name << "' on " << config.path
<< '\n';
cs::UsbCamera camera{config.name, config.path};
auto inst = frc::CameraServer::GetInstance();
cs::UsbCamera camera{config.name, config.path};
auto server = inst->StartAutomaticCapture(camera);

camera.SetConfigJson(config.config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public static boolean readConfig() {
*/
public static VideoSource startCamera(CameraConfig config) {
System.out.println("Starting camera '" + config.name + "' on " + config.path);
UsbCamera camera = new UsbCamera(config.name, config.path);
CameraServer inst = CameraServer.getInstance();
UsbCamera camera = new UsbCamera(config.name, config.path);
MjpegServer server = inst.startAutomaticCapture(camera);

Gson gson = new GsonBuilder().create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def readConfig():
"""Start running the camera."""
def startCamera(config):
print("Starting camera '{}' on {}".format(config.name, config.path))
camera = UsbCamera(config.name, config.path)
inst = CameraServer.getInstance()
camera = UsbCamera(config.name, config.path)
server = inst.startAutomaticCapture(camera=camera, return_server=True)

camera.setConfigJson(json.dumps(config.config))
Expand Down
2 changes: 1 addition & 1 deletion deps/tools/multiCameraServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ bool ReadConfig() {
void StartCamera(const CameraConfig& config) {
wpi::outs() << "Starting camera '" << config.name << "' on " << config.path
<< '\n';
cs::UsbCamera camera{config.name, config.path};
auto inst = frc::CameraServer::GetInstance();
cs::UsbCamera camera{config.name, config.path};
auto server = inst->StartAutomaticCapture(camera);

camera.SetConfigJson(config.config);
Expand Down

0 comments on commit 08163c0

Please sign in to comment.