mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
cscore: Use Twine instead of StringRef in API (#1244)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "cscore_c.h"
|
||||
|
||||
@@ -104,29 +105,29 @@ struct RawEvent {
|
||||
|
||||
RawEvent() = default;
|
||||
explicit RawEvent(RawEvent::Kind kind_) : kind{kind_} {}
|
||||
RawEvent(wpi::StringRef name_, CS_Handle handle_, RawEvent::Kind kind_)
|
||||
: kind{kind_}, name{name_} {
|
||||
RawEvent(const wpi::Twine& name_, CS_Handle handle_, RawEvent::Kind kind_)
|
||||
: kind{kind_}, name{name_.str()} {
|
||||
if (kind_ == kSinkCreated || kind_ == kSinkDestroyed ||
|
||||
kind_ == kSinkEnabled || kind_ == kSinkDisabled)
|
||||
sinkHandle = handle_;
|
||||
else
|
||||
sourceHandle = handle_;
|
||||
}
|
||||
RawEvent(wpi::StringRef name_, CS_Source source_, const VideoMode& mode_)
|
||||
RawEvent(const wpi::Twine& name_, CS_Source source_, const VideoMode& mode_)
|
||||
: kind{kSourceVideoModeChanged},
|
||||
sourceHandle{source_},
|
||||
name{name_},
|
||||
name{name_.str()},
|
||||
mode{mode_} {}
|
||||
RawEvent(wpi::StringRef name_, CS_Source source_, RawEvent::Kind kind_,
|
||||
RawEvent(const wpi::Twine& name_, CS_Source source_, RawEvent::Kind kind_,
|
||||
CS_Property property_, CS_PropertyKind propertyKind_, int value_,
|
||||
wpi::StringRef valueStr_)
|
||||
const wpi::Twine& valueStr_)
|
||||
: kind{kind_},
|
||||
sourceHandle{source_},
|
||||
name{name_},
|
||||
name{name_.str()},
|
||||
propertyHandle{property_},
|
||||
propertyKind{propertyKind_},
|
||||
value{value_},
|
||||
valueStr{valueStr_} {}
|
||||
valueStr{valueStr_.str()} {}
|
||||
|
||||
Kind kind;
|
||||
|
||||
@@ -166,7 +167,7 @@ std::string GetStringProperty(CS_Property property, CS_Status* status);
|
||||
wpi::StringRef GetStringProperty(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
void SetStringProperty(CS_Property property, wpi::StringRef value,
|
||||
void SetStringProperty(CS_Property property, const wpi::Twine& value,
|
||||
CS_Status* status);
|
||||
std::vector<std::string> GetEnumPropertyChoices(CS_Property property,
|
||||
CS_Status* status);
|
||||
@@ -176,14 +177,16 @@ std::vector<std::string> GetEnumPropertyChoices(CS_Property property,
|
||||
* @defgroup cscore_source_create_func Source Creation Functions
|
||||
* @{
|
||||
*/
|
||||
CS_Source CreateUsbCameraDev(wpi::StringRef name, int dev, CS_Status* status);
|
||||
CS_Source CreateUsbCameraPath(wpi::StringRef name, wpi::StringRef path,
|
||||
CS_Source CreateUsbCameraDev(const wpi::Twine& name, int dev,
|
||||
CS_Status* status);
|
||||
CS_Source CreateUsbCameraPath(const wpi::Twine& name, const wpi::Twine& path,
|
||||
CS_Status* status);
|
||||
CS_Source CreateHttpCamera(wpi::StringRef name, wpi::StringRef url,
|
||||
CS_Source CreateHttpCamera(const wpi::Twine& name, const wpi::Twine& url,
|
||||
CS_HttpCameraKind kind, CS_Status* status);
|
||||
CS_Source CreateHttpCamera(wpi::StringRef name, wpi::ArrayRef<std::string> urls,
|
||||
CS_Source CreateHttpCamera(const wpi::Twine& name,
|
||||
wpi::ArrayRef<std::string> urls,
|
||||
CS_HttpCameraKind kind, CS_Status* status);
|
||||
CS_Source CreateCvSource(wpi::StringRef name, const VideoMode& mode,
|
||||
CS_Source CreateCvSource(const wpi::Twine& name, const VideoMode& mode,
|
||||
CS_Status* status);
|
||||
/** @} */
|
||||
|
||||
@@ -201,7 +204,7 @@ wpi::StringRef GetSourceDescription(CS_Source source,
|
||||
CS_Status* status);
|
||||
uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status);
|
||||
bool IsSourceConnected(CS_Source source, CS_Status* status);
|
||||
CS_Property GetSourceProperty(CS_Source source, wpi::StringRef name,
|
||||
CS_Property GetSourceProperty(CS_Source source, const wpi::Twine& name,
|
||||
CS_Status* status);
|
||||
wpi::ArrayRef<CS_Property> EnumerateSourceProperties(
|
||||
CS_Source source, wpi::SmallVectorImpl<CS_Property>& vec,
|
||||
@@ -260,11 +263,12 @@ std::vector<std::string> GetHttpCameraUrls(CS_Source source, CS_Status* status);
|
||||
* @{
|
||||
*/
|
||||
void PutSourceFrame(CS_Source source, cv::Mat& image, CS_Status* status);
|
||||
void NotifySourceError(CS_Source source, wpi::StringRef msg, CS_Status* status);
|
||||
void NotifySourceError(CS_Source source, const wpi::Twine& msg,
|
||||
CS_Status* status);
|
||||
void SetSourceConnected(CS_Source source, bool connected, CS_Status* status);
|
||||
void SetSourceDescription(CS_Source source, wpi::StringRef description,
|
||||
void SetSourceDescription(CS_Source source, const wpi::Twine& description,
|
||||
CS_Status* status);
|
||||
CS_Property CreateSourceProperty(CS_Source source, wpi::StringRef name,
|
||||
CS_Property CreateSourceProperty(CS_Source source, const wpi::Twine& name,
|
||||
CS_PropertyKind kind, int minimum, int maximum,
|
||||
int step, int defaultValue, int value,
|
||||
CS_Status* status);
|
||||
@@ -277,10 +281,11 @@ void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
* @defgroup cscore_sink_create_func Sink Creation Functions
|
||||
* @{
|
||||
*/
|
||||
CS_Sink CreateMjpegServer(wpi::StringRef name, wpi::StringRef listenAddress,
|
||||
int port, CS_Status* status);
|
||||
CS_Sink CreateCvSink(wpi::StringRef name, CS_Status* status);
|
||||
CS_Sink CreateCvSinkCallback(wpi::StringRef name,
|
||||
CS_Sink CreateMjpegServer(const wpi::Twine& name,
|
||||
const wpi::Twine& listenAddress, int port,
|
||||
CS_Status* status);
|
||||
CS_Sink CreateCvSink(const wpi::Twine& name, CS_Status* status);
|
||||
CS_Sink CreateCvSinkCallback(const wpi::Twine& name,
|
||||
std::function<void(uint64_t time)> processFrame,
|
||||
CS_Status* status);
|
||||
/** @} */
|
||||
@@ -296,12 +301,12 @@ wpi::StringRef GetSinkName(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
std::string GetSinkDescription(CS_Sink sink, CS_Status* status);
|
||||
wpi::StringRef GetSinkDescription(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
CS_Property GetSinkProperty(CS_Sink sink, wpi::StringRef name,
|
||||
CS_Property GetSinkProperty(CS_Sink sink, const wpi::Twine& name,
|
||||
CS_Status* status);
|
||||
wpi::ArrayRef<CS_Property> EnumerateSinkProperties(
|
||||
CS_Sink sink, wpi::SmallVectorImpl<CS_Property>& vec, CS_Status* status);
|
||||
void SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status);
|
||||
CS_Property GetSinkSourceProperty(CS_Sink sink, wpi::StringRef name,
|
||||
CS_Property GetSinkSourceProperty(CS_Sink sink, const wpi::Twine& name,
|
||||
CS_Status* status);
|
||||
CS_Source GetSinkSource(CS_Sink sink, CS_Status* status);
|
||||
CS_Sink CopySink(CS_Sink sink, CS_Status* status);
|
||||
@@ -320,7 +325,7 @@ int GetMjpegServerPort(CS_Sink sink, CS_Status* status);
|
||||
* @defgroup cscore_opencv_sink_func OpenCV Sink Functions
|
||||
* @{
|
||||
*/
|
||||
void SetSinkDescription(CS_Sink sink, wpi::StringRef description,
|
||||
void SetSinkDescription(CS_Sink sink, const wpi::Twine& description,
|
||||
CS_Status* status);
|
||||
uint64_t GrabSinkFrame(CS_Sink sink, cv::Mat& image, CS_Status* status);
|
||||
uint64_t GrabSinkFrameTimeout(CS_Sink sink, cv::Mat& image, double timeout,
|
||||
|
||||
@@ -75,7 +75,7 @@ class VideoProperty {
|
||||
// String-specific functions
|
||||
std::string GetString() const;
|
||||
wpi::StringRef GetString(wpi::SmallVectorImpl<char>& buf) const;
|
||||
void SetString(wpi::StringRef value);
|
||||
void SetString(const wpi::Twine& value);
|
||||
|
||||
// Enum-specific functions
|
||||
std::vector<std::string> GetChoices() const;
|
||||
@@ -157,7 +157,7 @@ class VideoSource {
|
||||
* @return Property contents (of kind Property::kNone if no property with
|
||||
* the given name exists)
|
||||
*/
|
||||
VideoProperty GetProperty(wpi::StringRef name);
|
||||
VideoProperty GetProperty(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Enumerate all properties of this source.
|
||||
@@ -337,7 +337,7 @@ class UsbCamera : public VideoCamera {
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
* @param dev Device number (e.g. 0 for /dev/video0)
|
||||
*/
|
||||
UsbCamera(wpi::StringRef name, int dev);
|
||||
UsbCamera(const wpi::Twine& name, int dev);
|
||||
|
||||
/**
|
||||
* Create a source for a USB camera based on device path.
|
||||
@@ -345,7 +345,7 @@ class UsbCamera : public VideoCamera {
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
* @param path Path to device (e.g. "/dev/video0" on Linux)
|
||||
*/
|
||||
UsbCamera(wpi::StringRef name, wpi::StringRef path);
|
||||
UsbCamera(const wpi::Twine& name, const wpi::Twine& path);
|
||||
|
||||
/**
|
||||
* Enumerate USB cameras on the local system.
|
||||
@@ -386,7 +386,7 @@ class HttpCamera : public VideoCamera {
|
||||
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
HttpCamera(wpi::StringRef name, wpi::StringRef url,
|
||||
HttpCamera(const wpi::Twine& name, const wpi::Twine& url,
|
||||
HttpCameraKind kind = kUnknown);
|
||||
|
||||
/**
|
||||
@@ -396,7 +396,7 @@ class HttpCamera : public VideoCamera {
|
||||
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
HttpCamera(wpi::StringRef name, const char* url,
|
||||
HttpCamera(const wpi::Twine& name, const char* url,
|
||||
HttpCameraKind kind = kUnknown);
|
||||
|
||||
/**
|
||||
@@ -406,7 +406,7 @@ class HttpCamera : public VideoCamera {
|
||||
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
HttpCamera(wpi::StringRef name, const std::string& url,
|
||||
HttpCamera(const wpi::Twine& name, const std::string& url,
|
||||
HttpCameraKind kind = kUnknown);
|
||||
|
||||
/**
|
||||
@@ -416,7 +416,7 @@ class HttpCamera : public VideoCamera {
|
||||
* @param urls Array of Camera URLs
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
HttpCamera(wpi::StringRef name, wpi::ArrayRef<std::string> urls,
|
||||
HttpCamera(const wpi::Twine& name, wpi::ArrayRef<std::string> urls,
|
||||
HttpCameraKind kind = kUnknown);
|
||||
|
||||
/**
|
||||
@@ -427,7 +427,7 @@ class HttpCamera : public VideoCamera {
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
template <typename T>
|
||||
HttpCamera(wpi::StringRef name, std::initializer_list<T> urls,
|
||||
HttpCamera(const wpi::Twine& name, std::initializer_list<T> urls,
|
||||
HttpCameraKind kind = kUnknown);
|
||||
|
||||
/**
|
||||
@@ -459,7 +459,7 @@ class HttpCamera : public VideoCamera {
|
||||
* A source that represents an Axis IP camera.
|
||||
*/
|
||||
class AxisCamera : public HttpCamera {
|
||||
static std::string HostToUrl(wpi::StringRef host);
|
||||
static std::string HostToUrl(const wpi::Twine& host);
|
||||
static std::vector<std::string> HostToUrl(wpi::ArrayRef<std::string> hosts);
|
||||
template <typename T>
|
||||
static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
|
||||
@@ -472,7 +472,7 @@ class AxisCamera : public HttpCamera {
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
AxisCamera(wpi::StringRef name, wpi::StringRef host);
|
||||
AxisCamera(const wpi::Twine& name, const wpi::Twine& host);
|
||||
|
||||
/**
|
||||
* Create a source for an Axis IP camera.
|
||||
@@ -481,7 +481,7 @@ class AxisCamera : public HttpCamera {
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
AxisCamera(wpi::StringRef name, const char* host);
|
||||
AxisCamera(const wpi::Twine& name, const char* host);
|
||||
|
||||
/**
|
||||
* Create a source for an Axis IP camera.
|
||||
@@ -490,7 +490,7 @@ class AxisCamera : public HttpCamera {
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
AxisCamera(wpi::StringRef name, const std::string& host);
|
||||
AxisCamera(const wpi::Twine& name, const std::string& host);
|
||||
|
||||
/**
|
||||
* Create a source for an Axis IP camera.
|
||||
@@ -499,7 +499,7 @@ class AxisCamera : public HttpCamera {
|
||||
* @param hosts Array of Camera host IPs/DNS names
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
AxisCamera(wpi::StringRef name, wpi::ArrayRef<std::string> hosts);
|
||||
AxisCamera(const wpi::Twine& name, wpi::ArrayRef<std::string> hosts);
|
||||
|
||||
/**
|
||||
* Create a source for an Axis IP camera.
|
||||
@@ -509,7 +509,7 @@ class AxisCamera : public HttpCamera {
|
||||
* @param kind Camera kind (e.g. kAxis)
|
||||
*/
|
||||
template <typename T>
|
||||
AxisCamera(wpi::StringRef name, std::initializer_list<T> hosts);
|
||||
AxisCamera(const wpi::Twine& name, std::initializer_list<T> hosts);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -525,7 +525,7 @@ class CvSource : public VideoSource {
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
* @param mode Video mode being generated
|
||||
*/
|
||||
CvSource(wpi::StringRef name, const VideoMode& mode);
|
||||
CvSource(const wpi::Twine& name, const VideoMode& mode);
|
||||
|
||||
/**
|
||||
* Create an OpenCV source.
|
||||
@@ -536,8 +536,8 @@ class CvSource : public VideoSource {
|
||||
* @param height height
|
||||
* @param fps fps
|
||||
*/
|
||||
CvSource(wpi::StringRef name, VideoMode::PixelFormat pixelFormat, int width,
|
||||
int height, int fps);
|
||||
CvSource(const wpi::Twine& name, VideoMode::PixelFormat pixelFormat,
|
||||
int width, int height, int fps);
|
||||
|
||||
/**
|
||||
* Put an OpenCV image and notify sinks.
|
||||
@@ -554,7 +554,7 @@ class CvSource : public VideoSource {
|
||||
* Signal sinks that an error has occurred. This should be called instead
|
||||
* of NotifyFrame when an error occurs.
|
||||
*/
|
||||
void NotifyError(wpi::StringRef msg);
|
||||
void NotifyError(const wpi::Twine& msg);
|
||||
|
||||
/**
|
||||
* Set source connection status. Defaults to true.
|
||||
@@ -568,7 +568,7 @@ class CvSource : public VideoSource {
|
||||
*
|
||||
* @param description Description
|
||||
*/
|
||||
void SetDescription(wpi::StringRef description);
|
||||
void SetDescription(const wpi::Twine& description);
|
||||
|
||||
/**
|
||||
* Create a property.
|
||||
@@ -582,7 +582,7 @@ class CvSource : public VideoSource {
|
||||
* @param value Current value
|
||||
* @return Property
|
||||
*/
|
||||
VideoProperty CreateProperty(wpi::StringRef name, VideoProperty::Kind kind,
|
||||
VideoProperty CreateProperty(const wpi::Twine& name, VideoProperty::Kind kind,
|
||||
int minimum, int maximum, int step,
|
||||
int defaultValue, int value);
|
||||
|
||||
@@ -597,7 +597,7 @@ class CvSource : public VideoSource {
|
||||
* @param value Current value
|
||||
* @return Property
|
||||
*/
|
||||
VideoProperty CreateIntegerProperty(wpi::StringRef name, int minimum,
|
||||
VideoProperty CreateIntegerProperty(const wpi::Twine& name, int minimum,
|
||||
int maximum, int step, int defaultValue,
|
||||
int value);
|
||||
|
||||
@@ -609,7 +609,7 @@ class CvSource : public VideoSource {
|
||||
* @param value Current value
|
||||
* @return Property
|
||||
*/
|
||||
VideoProperty CreateBooleanProperty(wpi::StringRef name, bool defaultValue,
|
||||
VideoProperty CreateBooleanProperty(const wpi::Twine& name, bool defaultValue,
|
||||
bool value);
|
||||
|
||||
/**
|
||||
@@ -620,7 +620,8 @@ class CvSource : public VideoSource {
|
||||
* @param value Current value
|
||||
* @return Property
|
||||
*/
|
||||
VideoProperty CreateStringProperty(wpi::StringRef name, wpi::StringRef value);
|
||||
VideoProperty CreateStringProperty(const wpi::Twine& name,
|
||||
const wpi::Twine& value);
|
||||
|
||||
/**
|
||||
* Configure enum property choices.
|
||||
@@ -695,7 +696,7 @@ class VideoSink {
|
||||
* @return Property (kind Property::kNone if no property with
|
||||
* the given name exists)
|
||||
*/
|
||||
VideoProperty GetProperty(wpi::StringRef name);
|
||||
VideoProperty GetProperty(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Enumerate all properties of this sink.
|
||||
@@ -725,7 +726,7 @@ class VideoSink {
|
||||
* @return Property (kind Property::kNone if no property with
|
||||
* the given name exists or no source connected)
|
||||
*/
|
||||
VideoProperty GetSourceProperty(wpi::StringRef name);
|
||||
VideoProperty GetSourceProperty(const wpi::Twine& name);
|
||||
|
||||
CS_Status GetLastStatus() const { return m_status; }
|
||||
|
||||
@@ -763,7 +764,8 @@ class MjpegServer : public VideoSink {
|
||||
* @param listenAddress TCP listen address (empty string for all addresses)
|
||||
* @param port TCP port number
|
||||
*/
|
||||
MjpegServer(wpi::StringRef name, wpi::StringRef listenAddress, int port);
|
||||
MjpegServer(const wpi::Twine& name, const wpi::Twine& listenAddress,
|
||||
int port);
|
||||
|
||||
/**
|
||||
* Create a MJPEG-over-HTTP server sink.
|
||||
@@ -771,7 +773,7 @@ class MjpegServer : public VideoSink {
|
||||
* @param name Sink name (arbitrary unique identifier)
|
||||
* @param port TCP port number
|
||||
*/
|
||||
MjpegServer(wpi::StringRef name, int port) : MjpegServer(name, "", port) {}
|
||||
MjpegServer(const wpi::Twine& name, int port) : MjpegServer(name, "", port) {}
|
||||
|
||||
/**
|
||||
* Get the listen address of the server.
|
||||
@@ -844,7 +846,7 @@ class CvSink : public VideoSink {
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
*/
|
||||
explicit CvSink(wpi::StringRef name);
|
||||
explicit CvSink(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Create a sink for accepting OpenCV images in a separate thread.
|
||||
@@ -858,14 +860,15 @@ class CvSink : public VideoSink {
|
||||
* or GetError() as needed, but should not call (except in very
|
||||
* unusual circumstances) WaitForImage().
|
||||
*/
|
||||
CvSink(wpi::StringRef name, std::function<void(uint64_t time)> processFrame);
|
||||
CvSink(const wpi::Twine& name,
|
||||
std::function<void(uint64_t time)> processFrame);
|
||||
|
||||
/**
|
||||
* Set sink description.
|
||||
*
|
||||
* @param description Description
|
||||
*/
|
||||
void SetDescription(wpi::StringRef description);
|
||||
void SetDescription(const wpi::Twine& description);
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
|
||||
@@ -56,7 +56,7 @@ inline wpi::StringRef VideoProperty::GetString(
|
||||
return GetStringProperty(m_handle, buf, &m_status);
|
||||
}
|
||||
|
||||
inline void VideoProperty::SetString(wpi::StringRef value) {
|
||||
inline void VideoProperty::SetString(const wpi::Twine& value) {
|
||||
m_status = 0;
|
||||
SetStringProperty(m_handle, value, &m_status);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ inline bool VideoSource::IsConnected() const {
|
||||
return IsSourceConnected(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline VideoProperty VideoSource::GetProperty(wpi::StringRef name) {
|
||||
inline VideoProperty VideoSource::GetProperty(const wpi::Twine& name) {
|
||||
m_status = 0;
|
||||
return VideoProperty{GetSourceProperty(m_handle, name, &m_status)};
|
||||
}
|
||||
@@ -215,11 +215,11 @@ inline void VideoCamera::SetExposureManual(int value) {
|
||||
SetCameraExposureManual(m_handle, value, &m_status);
|
||||
}
|
||||
|
||||
inline UsbCamera::UsbCamera(wpi::StringRef name, int dev) {
|
||||
inline UsbCamera::UsbCamera(const wpi::Twine& name, int dev) {
|
||||
m_handle = CreateUsbCameraDev(name, dev, &m_status);
|
||||
}
|
||||
|
||||
inline UsbCamera::UsbCamera(wpi::StringRef name, wpi::StringRef path) {
|
||||
inline UsbCamera::UsbCamera(const wpi::Twine& name, const wpi::Twine& path) {
|
||||
m_handle = CreateUsbCameraPath(name, path, &m_status);
|
||||
}
|
||||
|
||||
@@ -239,25 +239,25 @@ inline void UsbCamera::SetConnectVerbose(int level) {
|
||||
&m_status);
|
||||
}
|
||||
|
||||
inline HttpCamera::HttpCamera(wpi::StringRef name, wpi::StringRef url,
|
||||
inline HttpCamera::HttpCamera(const wpi::Twine& name, const wpi::Twine& url,
|
||||
HttpCameraKind kind) {
|
||||
m_handle = CreateHttpCamera(
|
||||
name, url, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
|
||||
&m_status);
|
||||
}
|
||||
|
||||
inline HttpCamera::HttpCamera(wpi::StringRef name, const char* url,
|
||||
inline HttpCamera::HttpCamera(const wpi::Twine& name, const char* url,
|
||||
HttpCameraKind kind) {
|
||||
m_handle = CreateHttpCamera(
|
||||
name, url, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
|
||||
&m_status);
|
||||
}
|
||||
|
||||
inline HttpCamera::HttpCamera(wpi::StringRef name, const std::string& url,
|
||||
inline HttpCamera::HttpCamera(const wpi::Twine& name, const std::string& url,
|
||||
HttpCameraKind kind)
|
||||
: HttpCamera(name, wpi::StringRef{url}, kind) {}
|
||||
: HttpCamera(name, wpi::Twine{url}, kind) {}
|
||||
|
||||
inline HttpCamera::HttpCamera(wpi::StringRef name,
|
||||
inline HttpCamera::HttpCamera(const wpi::Twine& name,
|
||||
wpi::ArrayRef<std::string> urls,
|
||||
HttpCameraKind kind) {
|
||||
m_handle = CreateHttpCamera(
|
||||
@@ -266,7 +266,7 @@ inline HttpCamera::HttpCamera(wpi::StringRef name,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline HttpCamera::HttpCamera(wpi::StringRef name,
|
||||
inline HttpCamera::HttpCamera(const wpi::Twine& name,
|
||||
std::initializer_list<T> urls,
|
||||
HttpCameraKind kind) {
|
||||
std::vector<std::string> vec;
|
||||
@@ -302,11 +302,8 @@ inline std::vector<std::string> HttpCamera::GetUrls() const {
|
||||
return ::cs::GetHttpCameraUrls(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline std::string AxisCamera::HostToUrl(wpi::StringRef host) {
|
||||
std::string rv{"http://"};
|
||||
rv += host;
|
||||
rv += "/mjpg/video.mjpg";
|
||||
return rv;
|
||||
inline std::string AxisCamera::HostToUrl(const wpi::Twine& host) {
|
||||
return ("http://" + host + "/mjpg/video.mjpg").str();
|
||||
}
|
||||
|
||||
inline std::vector<std::string> AxisCamera::HostToUrl(
|
||||
@@ -328,29 +325,29 @@ inline std::vector<std::string> AxisCamera::HostToUrl(
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline AxisCamera::AxisCamera(wpi::StringRef name, wpi::StringRef host)
|
||||
inline AxisCamera::AxisCamera(const wpi::Twine& name, const wpi::Twine& host)
|
||||
: HttpCamera(name, HostToUrl(host), kAxis) {}
|
||||
|
||||
inline AxisCamera::AxisCamera(wpi::StringRef name, const char* host)
|
||||
inline AxisCamera::AxisCamera(const wpi::Twine& name, const char* host)
|
||||
: HttpCamera(name, HostToUrl(host), kAxis) {}
|
||||
|
||||
inline AxisCamera::AxisCamera(wpi::StringRef name, const std::string& host)
|
||||
: HttpCamera(name, HostToUrl(wpi::StringRef{host}), kAxis) {}
|
||||
inline AxisCamera::AxisCamera(const wpi::Twine& name, const std::string& host)
|
||||
: HttpCamera(name, HostToUrl(wpi::Twine{host}), kAxis) {}
|
||||
|
||||
inline AxisCamera::AxisCamera(wpi::StringRef name,
|
||||
inline AxisCamera::AxisCamera(const wpi::Twine& name,
|
||||
wpi::ArrayRef<std::string> hosts)
|
||||
: HttpCamera(name, HostToUrl(hosts), kAxis) {}
|
||||
|
||||
template <typename T>
|
||||
inline AxisCamera::AxisCamera(wpi::StringRef name,
|
||||
inline AxisCamera::AxisCamera(const wpi::Twine& name,
|
||||
std::initializer_list<T> hosts)
|
||||
: HttpCamera(name, HostToUrl(hosts), kAxis) {}
|
||||
|
||||
inline CvSource::CvSource(wpi::StringRef name, const VideoMode& mode) {
|
||||
inline CvSource::CvSource(const wpi::Twine& name, const VideoMode& mode) {
|
||||
m_handle = CreateCvSource(name, mode, &m_status);
|
||||
}
|
||||
|
||||
inline CvSource::CvSource(wpi::StringRef name, VideoMode::PixelFormat format,
|
||||
inline CvSource::CvSource(const wpi::Twine& name, VideoMode::PixelFormat format,
|
||||
int width, int height, int fps) {
|
||||
m_handle =
|
||||
CreateCvSource(name, VideoMode{format, width, height, fps}, &m_status);
|
||||
@@ -361,7 +358,7 @@ inline void CvSource::PutFrame(cv::Mat& image) {
|
||||
PutSourceFrame(m_handle, image, &m_status);
|
||||
}
|
||||
|
||||
inline void CvSource::NotifyError(wpi::StringRef msg) {
|
||||
inline void CvSource::NotifyError(const wpi::Twine& msg) {
|
||||
m_status = 0;
|
||||
NotifySourceError(m_handle, msg, &m_status);
|
||||
}
|
||||
@@ -371,12 +368,12 @@ inline void CvSource::SetConnected(bool connected) {
|
||||
SetSourceConnected(m_handle, connected, &m_status);
|
||||
}
|
||||
|
||||
inline void CvSource::SetDescription(wpi::StringRef description) {
|
||||
inline void CvSource::SetDescription(const wpi::Twine& description) {
|
||||
m_status = 0;
|
||||
SetSourceDescription(m_handle, description, &m_status);
|
||||
}
|
||||
|
||||
inline VideoProperty CvSource::CreateProperty(wpi::StringRef name,
|
||||
inline VideoProperty CvSource::CreateProperty(const wpi::Twine& name,
|
||||
VideoProperty::Kind kind,
|
||||
int minimum, int maximum,
|
||||
int step, int defaultValue,
|
||||
@@ -387,7 +384,7 @@ inline VideoProperty CvSource::CreateProperty(wpi::StringRef name,
|
||||
minimum, maximum, step, defaultValue, value, &m_status)};
|
||||
}
|
||||
|
||||
inline VideoProperty CvSource::CreateIntegerProperty(wpi::StringRef name,
|
||||
inline VideoProperty CvSource::CreateIntegerProperty(const wpi::Twine& name,
|
||||
int minimum, int maximum,
|
||||
int step, int defaultValue,
|
||||
int value) {
|
||||
@@ -397,7 +394,7 @@ inline VideoProperty CvSource::CreateIntegerProperty(wpi::StringRef name,
|
||||
minimum, maximum, step, defaultValue, value, &m_status)};
|
||||
}
|
||||
|
||||
inline VideoProperty CvSource::CreateBooleanProperty(wpi::StringRef name,
|
||||
inline VideoProperty CvSource::CreateBooleanProperty(const wpi::Twine& name,
|
||||
bool defaultValue,
|
||||
bool value) {
|
||||
m_status = 0;
|
||||
@@ -406,8 +403,8 @@ inline VideoProperty CvSource::CreateBooleanProperty(wpi::StringRef name,
|
||||
0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0, &m_status)};
|
||||
}
|
||||
|
||||
inline VideoProperty CvSource::CreateStringProperty(wpi::StringRef name,
|
||||
wpi::StringRef value) {
|
||||
inline VideoProperty CvSource::CreateStringProperty(const wpi::Twine& name,
|
||||
const wpi::Twine& value) {
|
||||
m_status = 0;
|
||||
auto prop = VideoProperty{CreateSourceProperty(
|
||||
m_handle, name, static_cast<CS_PropertyKind>(static_cast<int>(VideoProperty::Kind::kString)),
|
||||
@@ -465,7 +462,7 @@ inline std::string VideoSink::GetDescription() const {
|
||||
return GetSinkDescription(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline VideoProperty VideoSink::GetProperty(wpi::StringRef name) {
|
||||
inline VideoProperty VideoSink::GetProperty(const wpi::Twine& name) {
|
||||
m_status = 0;
|
||||
return VideoProperty{GetSinkProperty(m_handle, name, &m_status)};
|
||||
}
|
||||
@@ -484,13 +481,13 @@ inline VideoSource VideoSink::GetSource() const {
|
||||
return VideoSource{handle == 0 ? 0 : CopySource(handle, &m_status)};
|
||||
}
|
||||
|
||||
inline VideoProperty VideoSink::GetSourceProperty(wpi::StringRef name) {
|
||||
inline VideoProperty VideoSink::GetSourceProperty(const wpi::Twine& name) {
|
||||
m_status = 0;
|
||||
return VideoProperty{GetSinkSourceProperty(m_handle, name, &m_status)};
|
||||
}
|
||||
|
||||
inline MjpegServer::MjpegServer(wpi::StringRef name,
|
||||
wpi::StringRef listenAddress, int port) {
|
||||
inline MjpegServer::MjpegServer(const wpi::Twine& name,
|
||||
const wpi::Twine& listenAddress, int port) {
|
||||
m_handle = CreateMjpegServer(name, listenAddress, port, &m_status);
|
||||
}
|
||||
|
||||
@@ -528,16 +525,16 @@ inline void MjpegServer::SetDefaultCompression(int quality) {
|
||||
quality, &m_status);
|
||||
}
|
||||
|
||||
inline CvSink::CvSink(wpi::StringRef name) {
|
||||
inline CvSink::CvSink(const wpi::Twine& name) {
|
||||
m_handle = CreateCvSink(name, &m_status);
|
||||
}
|
||||
|
||||
inline CvSink::CvSink(wpi::StringRef name,
|
||||
inline CvSink::CvSink(const wpi::Twine& name,
|
||||
std::function<void(uint64_t time)> processFrame) {
|
||||
m_handle = CreateCvSinkCallback(name, processFrame, &m_status);
|
||||
}
|
||||
|
||||
inline void CvSink::SetDescription(wpi::StringRef description) {
|
||||
inline void CvSink::SetDescription(const wpi::Twine& description) {
|
||||
m_status = 0;
|
||||
SetSinkDescription(m_handle, description, &m_status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user