8 #ifndef CSCORE_CSCORE_OO_H_
9 #define CSCORE_CSCORE_OO_H_
11 #include <initializer_list>
16 #include "cscore_cpp.h"
48 kBoolean = CS_PROP_BOOLEAN,
49 kInteger = CS_PROP_INTEGER,
50 kString = CS_PROP_STRING,
56 std::string GetName()
const;
58 Kind GetKind()
const {
return m_kind; }
60 explicit operator bool()
const {
return m_kind != kNone; }
63 bool IsBoolean()
const {
return m_kind == kBoolean; }
64 bool IsInteger()
const {
return m_kind == kInteger; }
65 bool IsString()
const {
return m_kind == kString; }
66 bool IsEnum()
const {
return m_kind == kEnum; }
73 int GetDefault()
const;
76 std::string GetString()
const;
81 std::vector<std::string> GetChoices()
const;
83 CS_Status GetLastStatus()
const {
return m_status; }
89 mutable CS_Status m_status;
103 kUnknown = CS_SOURCE_UNKNOWN,
104 kUsb = CS_SOURCE_USB,
105 kHttp = CS_SOURCE_HTTP,
131 VideoSource(
const VideoSource& source);
132 VideoSource(VideoSource&& other) noexcept;
133 VideoSource& operator=(VideoSource other) noexcept;
136 explicit operator bool()
const {
return m_handle != 0; }
138 int GetHandle()
const {
return m_handle; }
140 bool operator==(
const VideoSource& other)
const {
141 return m_handle == other.m_handle;
144 bool operator!=(
const VideoSource& other)
const {
return !(*
this == other); }
228 bool SetVideoMode(VideoMode::PixelFormat pixelFormat,
int width,
int height,
329 CS_Status GetLastStatus()
const {
return m_status; }
345 friend void swap(VideoSource& first, VideoSource& second) noexcept {
347 swap(first.m_status, second.m_status);
348 swap(first.m_handle, second.m_handle);
352 explicit VideoSource(CS_Source handle) : m_handle(handle) {}
354 mutable CS_Status m_status = 0;
365 kFixedOutdoor1 = 4000,
366 kFixedOutdoor2 = 5000,
367 kFixedFluorescent1 = 5100,
368 kFixedFlourescent2 = 5200
470 enum HttpCameraKind {
471 kUnknown = CS_HTTP_UNKNOWN,
472 kMJPGStreamer = CS_HTTP_MJPGSTREAMER,
473 kCSCore = CS_HTTP_CSCORE,
485 HttpCameraKind kind = kUnknown);
495 HttpCameraKind kind = kUnknown);
505 HttpCameraKind kind = kUnknown);
515 HttpCameraKind kind = kUnknown);
524 template <
typename T>
526 HttpCameraKind kind = kUnknown);
544 template <
typename T>
545 void SetUrls(std::initializer_list<T> urls);
550 std::vector<std::string>
GetUrls()
const;
557 static std::string HostToUrl(
const wpi::Twine& host);
559 template <
typename T>
560 static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
615 template <
typename T>
660 int minimum,
int maximum,
int step,
661 int defaultValue,
int value);
675 int maximum,
int step,
int defaultValue,
715 template <
typename T>
717 std::initializer_list<T> choices);
729 kUnknown = CS_SINK_UNKNOWN,
730 kMjpeg = CS_SINK_MJPEG,
740 explicit operator bool()
const {
return m_handle != 0; }
742 int GetHandle()
const {
return m_handle; }
744 bool operator==(
const VideoSink& other)
const {
745 return m_handle == other.m_handle;
748 bool operator!=(
const VideoSink& other)
const {
return !(*
this == other); }
848 CS_Status GetLastStatus()
const {
return m_status; }
859 swap(first.m_status, second.m_status);
860 swap(first.m_handle, second.m_handle);
864 explicit VideoSink(CS_Sink handle) : m_handle(handle) {}
866 mutable CS_Status m_status = 0;
1020 int eventMask,
bool immediateNotify);
1030 swap(first.m_handle, second.m_handle);
1034 CS_Listener m_handle;
1041 #include "cscore_oo.inl"
1043 #endif // CSCORE_CSCORE_OO_H_
a class to store JSON values
Definition: json.h:2655
void SetWhiteBalanceAuto()
Set the white balance to auto.
Definition: cscore_oo.inl:215
VideoProperty CreateBooleanProperty(const wpi::Twine &name, bool defaultValue, bool value)
Create a boolean property.
Definition: cscore_oo.inl:417
bool SetVideoMode(const VideoMode &mode)
Set the video mode.
Definition: cscore_oo.inl:146
std::string GetName() const
Get the name of the sink.
Definition: cscore_oo.inl:475
void NotifyError(const wpi::Twine &msg)
Signal sinks that an error has occurred.
Definition: cscore_oo.inl:381
double GetActualFPS() const
Get the actual FPS.
Definition: cscore_oo.inl:188
UsbCameraInfo GetInfo() const
Get the full camera information for the device.
Definition: cscore_oo.inl:263
void SetWhiteBalanceManual(int value)
Set the white balance to manual, with specified color temperature.
Definition: cscore_oo.inl:225
VideoProperty GetProperty(const wpi::Twine &name)
Get a property of the sink.
Definition: cscore_oo.inl:485
A source that represents an Axis IP camera.
Definition: cscore_oo.h:556
A sink for video that accepts a sequence of frames.
Definition: cscore_oo.h:723
void SetBrightness(int brightness)
Set the brightness, as a percentage (0-100).
Definition: cscore_oo.inl:205
void SetConnectVerbose(int level)
Set how verbose the camera connection messages are.
Definition: cscore_oo.inl:268
double GetActualDataRate() const
Get the data rate (in bytes per second).
Definition: cscore_oo.inl:194
std::string GetConfigJson() const
Get a JSON configuration string.
Definition: cscore_oo.inl:183
Listener event.
Definition: cscore_cpp.h:102
A source that represents a USB camera.
Definition: cscore_oo.h:420
wpi::json GetConfigJsonObject() const
Get a JSON configuration object.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:42
void SetExposureHoldCurrent()
Set the exposure to hold current.
Definition: cscore_oo.inl:235
A source or sink property.
Definition: cscore_oo.h:39
Try to keep the connection open regardless of whether any sinks are connected.
Definition: cscore_c.h:198
VideoProperty CreateIntegerProperty(const wpi::Twine &name, int minimum, int maximum, int step, int defaultValue, int value)
Create an integer property.
Definition: cscore_oo.inl:407
Never open the connection.
Definition: cscore_oo.h:127
A source that represents a video camera.
Definition: cscore_oo.h:361
void SetConnected(bool connected)
Set source connection status.
Definition: cscore_oo.inl:386
Kind GetKind() const
Get the kind of the source.
Definition: cscore_oo.inl:99
std::string GetPath() const
Get the path to the device.
Definition: cscore_oo.inl:258
HttpCameraKind GetHttpCameraKind() const
Get the kind of HTTP camera.
Definition: cscore_oo.inl:312
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:873
void SetSource(VideoSource source)
Configure which source should provide frames to this sink.
Definition: cscore_oo.inl:490
std::vector< VideoProperty > EnumerateProperties() const
Enumerate all properties of this source.
static std::vector< UsbCameraInfo > EnumerateUsbCameras()
Enumerate USB cameras on the local system.
Definition: cscore_oo.inl:253
Automatically connect or disconnect based on whether any sinks are connected to this source.
Definition: cscore_c.h:192
void SetExposureManual(int value)
Set the exposure to manual, as a percentage (0-100).
Definition: cscore_oo.inl:240
HttpCamera(const wpi::Twine &name, const wpi::Twine &url, HttpCameraKind kind=kUnknown)
Create a source for a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.inl:274
bool SetFPS(int fps)
Set the frames per second (FPS).
Definition: cscore_oo.inl:168
bool SetConfigJson(wpi::StringRef config)
Set properties from a JSON configuration string.
Definition: cscore_oo.inl:509
An event generated by the library and provided to event listeners.
Definition: cscore_oo.h:985
int GetPort() const
Get the port number of the server.
Definition: cscore_oo.inl:534
std::vector< VideoSink > EnumerateSinks()
Enumerate all sinks connected to this source.
std::vector< std::string > GetUrls() const
Get the URLs used to connect to the camera.
Definition: cscore_oo.inl:332
An event listener.
Definition: cscore_oo.h:1007
A base class for single image reading sinks.
Definition: cscore_oo.h:954
std::string GetListenAddress() const
Get the listen address of the server.
Definition: cscore_oo.inl:529
void SetWhiteBalanceHoldCurrent()
Set the white balance to hold current.
Definition: cscore_oo.inl:220
CameraServer (cscore) namespace.
Definition: cscore_cpp.h:35
USB camera information.
Definition: cscore_cpp.h:50
static std::vector< VideoSource > EnumerateSources()
Enumerate all existing sources.
void SetConnectionStrategy(ConnectionStrategy strategy)
Sets the connection strategy.
Definition: cscore_oo.inl:119
std::vector< VideoMode > EnumerateVideoModes() const
Enumerate all known video modes for this source.
Definition: cscore_oo.inl:200
std::string GetConfigJson() const
Get a JSON configuration string.
Definition: cscore_oo.inl:519
VideoSource GetSource() const
Get the connected source.
Definition: cscore_oo.inl:498
bool SetConfigJson(wpi::StringRef config)
Set video mode and properties from a JSON configuration string.
Definition: cscore_oo.inl:173
VideoMode GetVideoMode() const
Get the current video mode.
Definition: cscore_oo.inl:141
void SetDescription(const wpi::Twine &description)
Set source description.
Definition: cscore_oo.inl:391
A source that represents a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.h:468
VideoSink GetSink() const
Get the sink associated with the event (if any).
Definition: cscore_oo.inl:583
void SetDefaultCompression(int quality)
Set the default compression used for non-MJPEG sources.
Definition: cscore_oo.inl:557
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Try to keep the connection open regardless of whether any sinks are connected.
Definition: cscore_oo.h:121
Automatically connect or disconnect based on whether any sinks are connected to this source.
Definition: cscore_oo.h:115
void SetResolution(int width, int height)
Set the stream resolution for clients that don't specify it.
Definition: cscore_oo.inl:539
VideoProperty GetProperty() const
Get the property associated with the event (if any).
Definition: cscore_oo.inl:588
bool SetResolution(int width, int height)
Set the resolution.
Definition: cscore_oo.inl:163
VideoProperty GetProperty(const wpi::Twine &name)
Get a property.
Definition: cscore_oo.inl:136
uint64_t GetLastFrameTime() const
Get the last time a frame was captured.
Definition: cscore_oo.inl:114
wpi::json GetConfigJsonObject() const
Get a JSON configuration object.
VideoProperty CreateProperty(const wpi::Twine &name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, int value)
Create a property.
Definition: cscore_oo.inl:396
Never open the connection.
Definition: cscore_c.h:204
ConnectionStrategy
Connection strategy.
Definition: cscore_oo.h:110
void SetExposureAuto()
Set the exposure to auto aperature.
Definition: cscore_oo.inl:230
std::string GetName() const
Get the name of the source.
Definition: cscore_oo.inl:104
void SetEnabled(bool enabled)
Enable or disable getting new frames.
Definition: cscore_oo.inl:573
Kind GetKind() const
Get the kind of the sink.
Definition: cscore_oo.inl:470
std::string GetDescription() const
Get the sink description.
Definition: cscore_oo.inl:480
A source for video that provides a sequence of frames.
Definition: cscore_oo.h:97
static std::vector< VideoSink > EnumerateSinks()
Enumerate all existing sinks.
void SetUrls(wpi::ArrayRef< std::string > urls)
Change the URLs used to connect to the camera.
Definition: cscore_oo.inl:318
MjpegServer(const wpi::Twine &name, int port)
Create a MJPEG-over-HTTP server sink.
Definition: cscore_oo.h:893
VideoProperty GetSourceProperty(const wpi::Twine &name)
Get a property of the associated source.
Definition: cscore_oo.inl:504
std::vector< VideoProperty > EnumerateProperties() const
Enumerate all properties of this sink.
AxisCamera(const wpi::Twine &name, const wpi::Twine &host)
Create a source for an Axis IP camera.
Definition: cscore_oo.inl:360
bool SetPixelFormat(VideoMode::PixelFormat pixelFormat)
Set the pixel format.
Definition: cscore_oo.inl:158
void SetFPS(int fps)
Set the stream frames per second (FPS) for clients that don't specify it.
Definition: cscore_oo.inl:546
void SetDescription(const wpi::Twine &description)
Set sink description.
Definition: cscore_oo.inl:563
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
VideoProperty CreateStringProperty(const wpi::Twine &name, const wpi::Twine &value)
Create a string property.
Definition: cscore_oo.inl:426
void SetEnumPropertyChoices(const VideoProperty &property, wpi::ArrayRef< std::string > choices)
Configure enum property choices.
Definition: cscore_oo.inl:437
std::string GetDescription() const
Get the source description.
Definition: cscore_oo.inl:109
int GetBrightness()
Get the brightness, as a percentage (0-100).
Definition: cscore_oo.inl:210
A base class for single image providing sources.
Definition: cscore_oo.h:622
bool IsEnabled() const
Gets source enable status.
Definition: cscore_oo.inl:131
std::string GetError() const
Get error string.
Definition: cscore_oo.inl:568
bool IsConnected() const
Is the source currently connected to whatever is providing the images?
Definition: cscore_oo.inl:126
void SetCompression(int quality)
Set the compression for clients that don't specify it.
Definition: cscore_oo.inl:551
VideoSource GetSource() const
Get the source associated with the event (if any).
Definition: cscore_oo.inl:578