mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Use std::string_view and fmtlib across all libraries (#3402)
- Twine, StringRef, Format, and NativeFormatting have been removed - Logging now uses fmtlib style formatting - Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or std::puts()/std::fputs() (for unformatted strings). - A wpi/fmt/raw_ostream.h header has been added to enable fmt::print() with wpi::raw_ostream
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <cstdio>
|
||||
#include <thread>
|
||||
|
||||
#include <cameraserver/CameraServer.h>
|
||||
@@ -9,7 +10,6 @@
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/core/types.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of OpenCV to do vision processing. The
|
||||
@@ -18,7 +18,7 @@
|
||||
* processing.
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
|
||||
private:
|
||||
static void VisionThread() {
|
||||
@@ -60,12 +60,12 @@ class Robot : public frc::TimedRobot {
|
||||
void RobotInit() override {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
#else
|
||||
wpi::errs() << "Vision only available on Linux.\n";
|
||||
wpi::errs().flush();
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <cameraserver/CameraServer.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
/**
|
||||
* Uses the CameraServer class to automatically capture video from a USB webcam
|
||||
@@ -15,11 +16,11 @@
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
frc::CameraServer::GetInstance()->StartAutomaticCapture();
|
||||
#else
|
||||
wpi::errs() << "Vision only available on Linux.\n";
|
||||
wpi::errs().flush();
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user