mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Deprecate getInstance() in favor of static functions (#3440)
Co-authored-by: Noam Zaks <imnoamzaks@gmail.com>
This commit is contained in:
@@ -19,15 +19,15 @@ class Robot : public frc::TimedRobot {
|
||||
static void VisionThread() {
|
||||
// Get the Axis camera from CameraServer
|
||||
cs::AxisCamera camera =
|
||||
frc::CameraServer::GetInstance()->AddAxisCamera("axis-camera.local");
|
||||
frc::CameraServer::AddAxisCamera("axis-camera.local");
|
||||
// Set the resolution
|
||||
camera.SetResolution(640, 480);
|
||||
|
||||
// Get a CvSink. This will capture Mats from the Camera
|
||||
cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo();
|
||||
cs::CvSink cvSink = frc::CameraServer::GetVideo();
|
||||
// Setup a CvSource. This will send images back to the Dashboard
|
||||
cs::CvSource outputStream =
|
||||
frc::CameraServer::GetInstance()->PutVideo("Rectangle", 640, 480);
|
||||
frc::CameraServer::PutVideo("Rectangle", 640, 480);
|
||||
|
||||
// Mats are very memory expensive. Lets reuse this Mat.
|
||||
cv::Mat mat;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/Timer.h>
|
||||
#include <frc/drive/DifferentialDrive.h>
|
||||
#include <frc/livewindow/LiveWindow.h>
|
||||
#include <frc/motorcontrol/PWMSparkMax.h>
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
@@ -50,7 +49,6 @@ class Robot : public frc::TimedRobot {
|
||||
frc::DifferentialDrive m_robotDrive{m_left, m_right};
|
||||
|
||||
frc::Joystick m_stick{0};
|
||||
frc::LiveWindow& m_lw = *frc::LiveWindow::GetInstance();
|
||||
frc::Timer m_timer;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,16 +23,15 @@ class Robot : public frc::TimedRobot {
|
||||
private:
|
||||
static void VisionThread() {
|
||||
// Get the USB camera from CameraServer
|
||||
cs::UsbCamera camera =
|
||||
frc::CameraServer::GetInstance()->StartAutomaticCapture();
|
||||
cs::UsbCamera camera = frc::CameraServer::StartAutomaticCapture();
|
||||
// Set the resolution
|
||||
camera.SetResolution(640, 480);
|
||||
|
||||
// Get a CvSink. This will capture Mats from the Camera
|
||||
cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo();
|
||||
cs::CvSink cvSink = frc::CameraServer::GetVideo();
|
||||
// Setup a CvSource. This will send images back to the Dashboard
|
||||
cs::CvSource outputStream =
|
||||
frc::CameraServer::GetInstance()->PutVideo("Rectangle", 640, 480);
|
||||
frc::CameraServer::PutVideo("Rectangle", 640, 480);
|
||||
|
||||
// Mats are very memory expensive. Lets reuse this Mat.
|
||||
cv::Mat mat;
|
||||
|
||||
@@ -17,7 +17,7 @@ class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
frc::CameraServer::GetInstance()->StartAutomaticCapture();
|
||||
frc::CameraServer::StartAutomaticCapture();
|
||||
#else
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
|
||||
Reference in New Issue
Block a user