From 08163c06810aa506fea56d101e2a1e4d683e0b02 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 13 Jan 2019 21:23:44 -0800 Subject: [PATCH] Fix ordering between CameraServer.getInstance and UsbCamera creation (#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. --- deps/examples/cpp-multiCameraServer/main.cpp | 2 +- deps/examples/java-multiCameraServer/src/main/java/Main.java | 2 +- deps/examples/python-multiCameraServer/multiCameraServer.py | 2 +- deps/tools/multiCameraServer.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/examples/cpp-multiCameraServer/main.cpp b/deps/examples/cpp-multiCameraServer/main.cpp index fc7c35f..e90ecc3 100644 --- a/deps/examples/cpp-multiCameraServer/main.cpp +++ b/deps/examples/cpp-multiCameraServer/main.cpp @@ -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); diff --git a/deps/examples/java-multiCameraServer/src/main/java/Main.java b/deps/examples/java-multiCameraServer/src/main/java/Main.java index 5f7c061..ad200db 100644 --- a/deps/examples/java-multiCameraServer/src/main/java/Main.java +++ b/deps/examples/java-multiCameraServer/src/main/java/Main.java @@ -181,8 +181,8 @@ public final class Main { */ 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(); diff --git a/deps/examples/python-multiCameraServer/multiCameraServer.py b/deps/examples/python-multiCameraServer/multiCameraServer.py index d997581..165ce2f 100755 --- a/deps/examples/python-multiCameraServer/multiCameraServer.py +++ b/deps/examples/python-multiCameraServer/multiCameraServer.py @@ -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)) diff --git a/deps/tools/multiCameraServer.cpp b/deps/tools/multiCameraServer.cpp index 2aea5eb..7a49062 100644 --- a/deps/tools/multiCameraServer.cpp +++ b/deps/tools/multiCameraServer.cpp @@ -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);