5#ifndef CSCORE_CSCORE_OO_H_
6#define CSCORE_CSCORE_OO_H_
9#include <initializer_list>
80 explicit operator bool()
const {
return m_kind !=
kNone; }
256 explicit operator
bool()
const {
return m_handle != 0; }
664 template <
typename T>
679 void SetUrls(std::span<const std::string> urls);
684 template <
typename T>
685 void SetUrls(std::initializer_list<T> urls);
690 std::vector<std::string>
GetUrls()
const;
700 static std::vector<std::string> HostToUrl(std::span<const std::string> hosts);
701 template <
typename T>
702 static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
743 template <
typename T>
790 int minimum,
int maximum,
int step,
791 int defaultValue,
int value);
805 int maximum,
int step,
int defaultValue,
836 std::span<const std::string> choices);
844 template <
typename T>
846 std::initializer_list<T> choices);
879 explicit operator
bool()
const {
return m_handle != 0; }
1167 int eventMask,
bool immediateNotify);
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation source
Definition: ThirdPartyNotices.txt:112
A source that represents an Axis IP camera.
Definition: cscore_oo.h:698
A source that represents a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.h:601
HttpCamera(std::string_view name, std::string_view url, HttpCameraKind kind=kUnknown)
Create a source for a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.inc:289
std::vector< std::string > GetUrls() const
Get the URLs used to connect to the camera.
Definition: cscore_oo.inc:351
void SetUrls(std::span< const std::string > urls)
Change the URLs used to connect to the camera.
Definition: cscore_oo.inc:335
HttpCameraKind
HTTP camera kind.
Definition: cscore_oo.h:606
@ kMJPGStreamer
MJPG Streamer camera.
Definition: cscore_oo.h:610
@ kCSCore
CS Core camera.
Definition: cscore_oo.h:612
@ kAxis
Axis camera.
Definition: cscore_oo.h:614
@ kUnknown
Unknown camera kind.
Definition: cscore_oo.h:608
HttpCameraKind GetHttpCameraKind() const
Get the kind of HTTP camera.
Definition: cscore_oo.inc:329
A base class for single image reading sinks.
Definition: cscore_oo.h:1095
void SetEnabled(bool enabled)
Enable or disable getting new frames.
Definition: cscore_oo.inc:599
std::string GetError() const
Get error string.
Definition: cscore_oo.inc:594
void SetDescription(std::string_view description)
Set sink description.
Definition: cscore_oo.inc:589
A base class for single image providing sources.
Definition: cscore_oo.h:750
VideoProperty CreateBooleanProperty(std::string_view name, bool defaultValue, bool value)
Create a boolean property.
Definition: cscore_oo.inc:435
void SetDescription(std::string_view description)
Set source description.
Definition: cscore_oo.inc:406
VideoProperty CreateIntegerProperty(std::string_view name, int minimum, int maximum, int step, int defaultValue, int value)
Create an integer property.
Definition: cscore_oo.inc:422
VideoProperty CreateProperty(std::string_view name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, int value)
Create a property.
Definition: cscore_oo.inc:411
void NotifyError(std::string_view msg)
Signal sinks that an error has occurred.
Definition: cscore_oo.inc:396
void SetConnected(bool connected)
Set source connection status.
Definition: cscore_oo.inc:401
VideoProperty CreateStringProperty(std::string_view name, std::string_view value)
Create a string property.
Definition: cscore_oo.inc:446
void SetEnumPropertyChoices(const VideoProperty &property, std::span< const std::string > choices)
Configure enum property choices.
Definition: cscore_oo.inc:458
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:1015
void SetFPS(int fps)
Set the stream frames per second (FPS) for clients that don't specify it.
Definition: cscore_oo.inc:572
void SetResolution(int width, int height)
Set the stream resolution for clients that don't specify it.
Definition: cscore_oo.inc:565
std::string GetListenAddress() const
Get the listen address of the server.
Definition: cscore_oo.inc:555
MjpegServer(std::string_view name, int port)
Create a MJPEG-over-HTTP server sink.
Definition: cscore_oo.h:1034
void SetDefaultCompression(int quality)
Set the default compression used for non-MJPEG sources.
Definition: cscore_oo.inc:583
void SetCompression(int quality)
Set the compression for clients that don't specify it.
Definition: cscore_oo.inc:577
int GetPort() const
Get the port number of the server.
Definition: cscore_oo.inc:560
A source that represents a USB camera.
Definition: cscore_oo.h:548
UsbCameraInfo GetInfo() const
Get the full camera information for the device.
Definition: cscore_oo.inc:278
static std::vector< UsbCameraInfo > EnumerateUsbCameras()
Enumerate USB cameras on the local system.
Definition: cscore_oo.inc:263
std::string GetPath() const
Get the path to the device.
Definition: cscore_oo.inc:273
void SetConnectVerbose(int level)
Set how verbose the camera connection messages are.
Definition: cscore_oo.inc:283
void SetPath(std::string_view path)
Change the path to the device.
Definition: cscore_oo.inc:268
A source that represents a video camera.
Definition: cscore_oo.h:481
VideoCamera(CS_Source handle)
Definition: cscore_oo.h:542
void SetExposureAuto()
Set the exposure to auto aperature.
Definition: cscore_oo.inc:240
void SetWhiteBalanceManual(int value)
Set the white balance to manual, with specified color temperature.
Definition: cscore_oo.inc:235
void SetWhiteBalanceAuto()
Set the white balance to auto.
Definition: cscore_oo.inc:225
int GetBrightness()
Get the brightness, as a percentage (0-100).
Definition: cscore_oo.inc:220
void SetBrightness(int brightness)
Set the brightness, as a percentage (0-100).
Definition: cscore_oo.inc:215
void SetWhiteBalanceHoldCurrent()
Set the white balance to hold current.
Definition: cscore_oo.inc:230
void SetExposureManual(int value)
Set the exposure to manual, as a percentage (0-100).
Definition: cscore_oo.inc:250
WhiteBalance
White balance.
Definition: cscore_oo.h:486
@ kFixedOutdoor1
Fixed outdoor white balance 1.
Definition: cscore_oo.h:490
@ kFixedFlourescent2
Fixed fluorescent white balance 2.
Definition: cscore_oo.h:496
@ kFixedIndoor
Fixed indoor white balance.
Definition: cscore_oo.h:488
@ kFixedFluorescent1
Fixed fluorescent white balance 1.
Definition: cscore_oo.h:494
@ kFixedOutdoor2
Fixed outdoor white balance 2.
Definition: cscore_oo.h:492
void SetExposureHoldCurrent()
Set the exposure to hold current.
Definition: cscore_oo.inc:245
An event generated by the library and provided to event listeners.
Definition: cscore_oo.h:1126
VideoSink GetSink() const
Returns the sink associated with the event (if any).
Definition: cscore_oo.inc:609
VideoProperty GetProperty() const
Returns the property associated with the event (if any).
Definition: cscore_oo.inc:614
VideoSource GetSource() const
Returns the source associated with the event (if any).
Definition: cscore_oo.inc:604
An event listener.
Definition: cscore_oo.h:1154
friend void swap(VideoListener &first, VideoListener &second) noexcept
Definition: cscore_oo.h:1175
~VideoListener()
Definition: cscore_oo.inc:640
VideoListener & operator=(const VideoListener &)=delete
VideoListener(const VideoListener &)=delete
A source or sink property.
Definition: cscore_oo.h:39
int GetMin() const
Returns property minimum value.
Definition: cscore_oo.inc:35
int Get() const
Returns property value.
Definition: cscore_oo.inc:25
bool IsInteger() const
Returns true if property is an integer.
Definition: cscore_oo.h:94
void SetString(std::string_view value)
Sets the string property value.
Definition: cscore_oo.inc:66
bool IsEnum() const
Returns true if property is an enum.
Definition: cscore_oo.h:108
std::string GetName() const
Returns property name.
Definition: cscore_oo.inc:20
int GetDefault() const
Returns property default value.
Definition: cscore_oo.inc:50
Kind
Definition: cscore_oo.h:46
@ kString
String property.
Definition: cscore_oo.h:54
@ kInteger
Integer property.
Definition: cscore_oo.h:52
@ kEnum
Enum property.
Definition: cscore_oo.h:56
@ kBoolean
Boolean property.
Definition: cscore_oo.h:50
@ kNone
No specific property.
Definition: cscore_oo.h:48
CS_Status GetLastStatus() const
Returns the last status.
Definition: cscore_oo.h:194
void Set(int value)
Sets property value.
Definition: cscore_oo.inc:30
bool IsBoolean() const
Returns true if property is a boolean.
Definition: cscore_oo.h:87
std::vector< std::string > GetChoices() const
Returns the possible values for the enum property value.
Definition: cscore_oo.inc:71
int GetStep() const
Returns property step size.
Definition: cscore_oo.inc:45
Kind GetKind() const
Returns property kind.
Definition: cscore_oo.h:73
bool IsString() const
Returns true if property is a string.
Definition: cscore_oo.h:101
std::string GetString() const
Returns the string property value.
Definition: cscore_oo.inc:55
int GetMax() const
Returns property maximum value.
Definition: cscore_oo.inc:40
A sink for video that accepts a sequence of frames.
Definition: cscore_oo.h:852
void SetSource(VideoSource source)
Configure which source should provide frames to this sink.
Definition: cscore_oo.inc:515
Kind
Definition: cscore_oo.h:857
@ kCv
CV video sink.
Definition: cscore_oo.h:863
@ kUnknown
Unknown sink type.
Definition: cscore_oo.h:859
@ kRaw
Raw video sink.
Definition: cscore_oo.h:865
@ kMjpeg
MJPEG video sink.
Definition: cscore_oo.h:861
VideoProperty GetProperty(std::string_view name)
Get a property of the sink.
Definition: cscore_oo.inc:510
friend void swap(VideoSink &first, VideoSink &second) noexcept
Definition: cscore_oo.h:999
std::string GetDescription() const
Get the sink description.
Definition: cscore_oo.inc:505
std::vector< VideoProperty > EnumerateProperties() const
Enumerate all properties of this sink.
Kind GetKind() const
Get the kind of the sink.
Definition: cscore_oo.inc:495
VideoProperty GetSourceProperty(std::string_view name)
Get a property of the associated source.
Definition: cscore_oo.inc:530
bool SetConfigJson(std::string_view config)
Set properties from a JSON configuration string.
Definition: cscore_oo.inc:535
int GetHandle() const
Returns the VideoSink handle.
Definition: cscore_oo.h:886
VideoSource GetSource() const
Get the connected source.
Definition: cscore_oo.inc:524
CS_Status m_status
Definition: cscore_oo.h:1008
VideoSink() noexcept=default
std::string GetConfigJson() const
Get a JSON configuration string.
Definition: cscore_oo.inc:545
bool operator==(const VideoSink &other) const
Definition: cscore_oo.h:888
CS_Sink m_handle
Definition: cscore_oo.h:1009
VideoSink(CS_Sink handle)
Definition: cscore_oo.h:1006
static std::vector< VideoSink > EnumerateSinks()
Enumerate all existing sinks.
std::string GetName() const
Get the name of the sink.
Definition: cscore_oo.inc:500
CS_Status GetLastStatus() const
Definition: cscore_oo.h:990
wpi::json GetConfigJsonObject() const
Get a JSON configuration object.
A source for video that provides a sequence of frames.
Definition: cscore_oo.h:208
std::vector< VideoSink > EnumerateSinks()
Enumerate all sinks connected to this source.
bool SetPixelFormat(VideoMode::PixelFormat pixelFormat)
Set the pixel format.
Definition: cscore_oo.inc:168
double GetActualDataRate() const
Get the data rate (in bytes per second).
Definition: cscore_oo.inc:204
CS_Source m_handle
Video source handle.
Definition: cscore_oo.h:475
VideoSource() noexcept=default
VideoProperty GetProperty(std::string_view name)
Get a property.
Definition: cscore_oo.inc:146
VideoMode GetVideoMode() const
Get the current video mode.
Definition: cscore_oo.inc:151
CS_Status m_status
Definition: cscore_oo.h:472
int GetHandle() const
Definition: cscore_oo.h:258
friend void swap(VideoSource &first, VideoSource &second) noexcept
Definition: cscore_oo.h:463
VideoSource(CS_Source handle)
Definition: cscore_oo.h:470
std::vector< VideoProperty > EnumerateProperties() const
Enumerate all properties of this source.
bool IsConnected() const
Is the source currently connected to whatever is providing the images?
Definition: cscore_oo.inc:136
std::string GetDescription() const
Get the source description.
Definition: cscore_oo.inc:119
wpi::json GetConfigJsonObject() const
Get a JSON configuration object.
bool IsEnabled() const
Gets source enable status.
Definition: cscore_oo.inc:141
ConnectionStrategy
Connection strategy.
Definition: cscore_oo.h:230
@ kConnectionKeepOpen
Try to keep the connection open regardless of whether any sinks are connected.
Definition: cscore_oo.h:241
@ kConnectionAutoManage
Automatically connect or disconnect based on whether any sinks are connected to this source.
Definition: cscore_oo.h:235
@ kConnectionForceClose
Never open the connection.
Definition: cscore_oo.h:247
std::vector< VideoMode > EnumerateVideoModes() const
Enumerate all known video modes for this source.
Definition: cscore_oo.inc:210
uint64_t GetLastFrameTime() const
Get the last time a frame was captured.
Definition: cscore_oo.inc:124
double GetActualFPS() const
Get the actual FPS.
Definition: cscore_oo.inc:198
bool operator==(const VideoSource &other) const
Definition: cscore_oo.h:260
Kind
Video source kind.
Definition: cscore_oo.h:216
@ kCv
CV video source.
Definition: cscore_oo.h:224
@ kHttp
HTTP video source.
Definition: cscore_oo.h:222
@ kRaw
Raw video source.
Definition: cscore_oo.h:226
@ kUnknown
Unknown video source.
Definition: cscore_oo.h:218
@ kUsb
USB video source.
Definition: cscore_oo.h:220
bool SetConfigJson(std::string_view config)
Set video mode and properties from a JSON configuration string.
Definition: cscore_oo.inc:183
bool SetFPS(int fps)
Set the frames per second (FPS).
Definition: cscore_oo.inc:178
static std::vector< VideoSource > EnumerateSources()
Enumerate all existing sources.
void SetConnectionStrategy(ConnectionStrategy strategy)
Sets the connection strategy.
Definition: cscore_oo.inc:129
CS_Status GetLastStatus() const
Definition: cscore_oo.h:447
Kind GetKind() const
Get the kind of the source.
Definition: cscore_oo.inc:109
std::string GetConfigJson() const
Get a JSON configuration string.
Definition: cscore_oo.inc:193
bool SetResolution(int width, int height)
Set the resolution.
Definition: cscore_oo.inc:173
bool SetVideoMode(const VideoMode &mode)
Set the video mode.
Definition: cscore_oo.inc:156
std::string GetName() const
Get the name of the source.
Definition: cscore_oo.inc:114
basic_string_view< char > string_view
Definition: core.h:518
@ CS_CONNECTION_AUTO_MANAGE
Automatically connect or disconnect based on whether any sinks are connected to this source.
Definition: cscore_c.h:182
@ CS_CONNECTION_KEEP_OPEN
Try to keep the connection open regardless of whether any sinks are connected.
Definition: cscore_c.h:188
@ CS_CONNECTION_FORCE_CLOSE
Never open the connection.
Definition: cscore_c.h:194
@ CS_HTTP_MJPGSTREAMER
Definition: cscore_c.h:127
@ CS_HTTP_CSCORE
Definition: cscore_c.h:128
@ CS_HTTP_UNKNOWN
Definition: cscore_c.h:126
@ CS_HTTP_AXIS
Definition: cscore_c.h:129
@ CS_PROP_ENUM
Definition: cscore_c.h:108
@ CS_PROP_NONE
Definition: cscore_c.h:104
@ CS_PROP_INTEGER
Definition: cscore_c.h:106
@ CS_PROP_BOOLEAN
Definition: cscore_c.h:105
@ CS_PROP_STRING
Definition: cscore_c.h:107
@ CS_SINK_MJPEG
Definition: cscore_c.h:137
@ CS_SINK_RAW
Definition: cscore_c.h:139
@ CS_SINK_CV
Definition: cscore_c.h:138
@ CS_SINK_UNKNOWN
Definition: cscore_c.h:136
@ CS_SOURCE_USB
Definition: cscore_c.h:116
@ CS_SOURCE_HTTP
Definition: cscore_c.h:117
@ CS_SOURCE_UNKNOWN
Definition: cscore_c.h:115
@ CS_SOURCE_RAW
Definition: cscore_c.h:119
@ CS_SOURCE_CV
Definition: cscore_c.h:118
CS_Handle CS_Source
Definition: cscore_c.h:54
int CS_Status
Definition: cscore_c.h:47
CS_Handle CS_Property
Definition: cscore_c.h:50
CS_Handle CS_Sink
Definition: cscore_c.h:53
CS_Handle CS_Listener
Definition: cscore_c.h:51
CameraServer (cscore) namespace.
Definition: cscore_cpp.h:29
auto first(const T &value, const Tail &...) -> const T &
Definition: compile.h:60
WPI_BASIC_JSON_TPL_DECLARATION void swap(wpi::WPI_BASIC_JSON_TPL &j1, wpi::WPI_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< wpi::WPI_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< wpi::WPI_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.h:5219
fps
Definition: velocity.h:46
constexpr const char * name(const T &)
Listener event.
Definition: cscore_cpp.h:102
USB camera information.
Definition: cscore_cpp.h:44
Video mode.
Definition: cscore_cpp.h:62
PixelFormat
Definition: cscore_cpp.h:63