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,
115 explicit operator bool()
const {
return m_handle != 0; }
117 int GetHandle()
const {
return m_handle; }
120 return m_handle == other.m_handle;
123 bool operator!=(
const VideoSource& other)
const {
return !(*
this == other); }
188 bool SetVideoMode(VideoMode::PixelFormat pixelFormat,
int width,
int height,
239 CS_Status GetLastStatus()
const {
return m_status; }
257 swap(first.m_status, second.m_status);
258 swap(first.m_handle, second.m_handle);
262 explicit VideoSource(CS_Source handle) : m_handle(handle) {}
264 mutable CS_Status m_status = 0;
275 kFixedOutdoor1 = 4000,
276 kFixedOutdoor2 = 5000,
277 kFixedFluorescent1 = 5100,
278 kFixedFlourescent2 = 5200
375 enum HttpCameraKind {
376 kUnknown = CS_HTTP_UNKNOWN,
377 kMJPGStreamer = CS_HTTP_MJPGSTREAMER,
378 kCSCore = CS_HTTP_CSCORE,
390 HttpCameraKind kind = kUnknown);
400 HttpCameraKind kind = kUnknown);
410 HttpCameraKind kind = kUnknown);
420 HttpCameraKind kind = kUnknown);
429 template <
typename T>
431 HttpCameraKind kind = kUnknown);
449 template <
typename T>
450 void SetUrls(std::initializer_list<T> urls);
455 std::vector<std::string>
GetUrls()
const;
464 template <
typename T>
465 static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
511 template <
typename T>
540 int height,
int fps);
586 int minimum,
int maximum,
int step,
587 int defaultValue,
int value);
601 int maximum,
int step,
int defaultValue,
640 template <
typename T>
642 std::initializer_list<T> choices);
654 kUnknown = CS_SINK_UNKNOWN,
655 kMjpeg = CS_SINK_MJPEG,
665 explicit operator bool()
const {
return m_handle != 0; }
667 int GetHandle()
const {
return m_handle; }
669 bool operator==(
const VideoSink& other)
const {
670 return m_handle == other.m_handle;
673 bool operator!=(
const VideoSink& other)
const {
return !(*
this == other); }
730 CS_Status GetLastStatus()
const {
return m_status; }
741 swap(first.m_status, second.m_status);
742 swap(first.m_handle, second.m_handle);
746 explicit VideoSink(CS_Sink handle) : m_handle(handle) {}
748 mutable CS_Status m_status = 0;
879 uint64_t
GrabFrame(cv::Mat& image,
double timeout = 0.225)
const;
945 int eventMask,
bool immediateNotify);
955 swap(first.m_handle, second.m_handle);
959 CS_Listener m_handle;
966 #include "cscore_oo.inl"
968 #endif // CSCORE_CSCORE_OO_H_
int GetPort() const
Get the port number of the server.
Definition: cscore_oo.inl:502
void SetWhiteBalanceManual(int value)
Set the white balance to manual, with specified color temperature.
Definition: cscore_oo.inl:198
void SetFPS(int fps)
Set the stream frames per second (FPS) for clients that don't specify it.
Definition: cscore_oo.inl:514
Definition: cscore_oo.inl:11
VideoSource GetSource() const
Get the connected source.
Definition: cscore_oo.inl:481
VideoProperty GetProperty(wpi::StringRef name)
Get a property.
Definition: cscore_oo.inl:124
void SetCompression(int quality)
Set the compression for clients that don't specify it.
Definition: cscore_oo.inl:519
VideoProperty GetSourceProperty(wpi::StringRef name)
Get a property of the associated source.
Definition: cscore_oo.inl:487
void SetSource(VideoSource source)
Configure which source should provide frames to this sink.
Definition: cscore_oo.inl:473
A source for video that provides a sequence of frames.
Definition: cscore_oo.h:97
VideoSink GetSink() const
Get the sink associated with the event (if any).
Definition: cscore_oo.inl:570
A sink for video that accepts a sequence of frames.
Definition: cscore_oo.h:648
void SetEnumPropertyChoices(const VideoProperty &property, wpi::ArrayRef< std::string > choices)
Configure enum property choices.
Definition: cscore_oo.inl:420
void SetExposureHoldCurrent()
Set the exposure to hold current.
Definition: cscore_oo.inl:208
std::vector< VideoMode > EnumerateVideoModes() const
Enumerate all known video modes for this source.
Definition: cscore_oo.inl:173
std::vector< VideoProperty > EnumerateProperties() const
Enumerate all properties of this sink.
An event generated by the library and provided to event listeners.
Definition: cscore_oo.h:910
VideoProperty CreateProperty(wpi::StringRef name, VideoProperty::Kind kind, int minimum, int maximum, int step, int defaultValue, int value)
Create a property.
Definition: cscore_oo.inl:379
bool IsConnected() const
Is the source currently connected to whatever is providing the images?
Definition: cscore_oo.inl:119
VideoProperty CreateStringProperty(wpi::StringRef name, wpi::StringRef value)
Create a string property.
Definition: cscore_oo.inl:409
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
Listener event.
Definition: cscore_cpp.h:81
std::vector< std::string > GetUrls() const
Get the URLs used to connect to the camera.
Definition: cscore_oo.inl:300
VideoProperty GetProperty(wpi::StringRef name)
Get a property of the sink.
Definition: cscore_oo.inl:468
A source that represents a USB camera.
Definition: cscore_oo.h:330
An event listener.
Definition: cscore_oo.h:932
uint64_t GrabFrame(cv::Mat &image, double timeout=0.225) const
Wait for the next frame and get the image.
Definition: cscore_oo.inl:545
A source that represents a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.h:373
std::vector< VideoProperty > EnumerateProperties() const
Enumerate all properties of this source.
HttpCameraKind GetHttpCameraKind() const
Get the kind of HTTP camera.
Definition: cscore_oo.inl:280
void SetExposureManual(int value)
Set the exposure to manual, as a percentage (0-100).
Definition: cscore_oo.inl:213
double GetActualFPS() const
Get the actual FPS.
Definition: cscore_oo.inl:161
VideoProperty CreateIntegerProperty(wpi::StringRef name, int minimum, int maximum, int step, int defaultValue, int value)
Create an integer property.
Definition: cscore_oo.inl:390
VideoProperty CreateBooleanProperty(wpi::StringRef name, bool defaultValue, bool value)
Create a boolean property.
Definition: cscore_oo.inl:400
std::string GetName() const
Get the name of the sink.
Definition: cscore_oo.inl:458
void SetDescription(wpi::StringRef description)
Set sink description.
Definition: cscore_oo.inl:540
uint64_t GrabFrameNoTimeout(cv::Mat &image) const
Wait for the next frame and get the image.
Definition: cscore_oo.inl:550
A source or sink property.
Definition: cscore_oo.h:39
Kind GetKind() const
Get the kind of the source.
Definition: cscore_oo.inl:99
HttpCamera(wpi::StringRef name, wpi::StringRef url, HttpCameraKind kind=kUnknown)
Create a source for a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.inl:242
std::string GetDescription() const
Get the source description.
Definition: cscore_oo.inl:109
void NotifyError(wpi::StringRef msg)
Signal sinks that an error has occurred.
Definition: cscore_oo.inl:364
std::string GetName() const
Get the name of the source.
Definition: cscore_oo.inl:104
bool SetFPS(int fps)
Set the frames per second (FPS).
Definition: cscore_oo.inl:156
std::string GetError() const
Get error string.
Definition: cscore_oo.inl:555
static std::vector< VideoSink > EnumerateSinks()
Enumerate all existing sinks.
std::vector< VideoSink > EnumerateSinks()
Enumerate all sinks connected to this source.
void SetDescription(wpi::StringRef description)
Set source description.
Definition: cscore_oo.inl:374
void SetResolution(int width, int height)
Set the stream resolution for clients that don't specify it.
Definition: cscore_oo.inl:507
void SetWhiteBalanceHoldCurrent()
Set the white balance to hold current.
Definition: cscore_oo.inl:193
static std::vector< VideoSource > EnumerateSources()
Enumerate all existing sources.
MjpegServer(wpi::StringRef name, int port)
Create a MJPEG-over-HTTP server sink.
Definition: cscore_oo.h:774
bool SetResolution(int width, int height)
Set the resolution.
Definition: cscore_oo.inl:151
static std::vector< UsbCameraInfo > EnumerateUsbCameras()
Enumerate USB cameras on the local system.
Definition: cscore_oo.inl:226
A source for user code to provide OpenCV images as video frames.
Definition: cscore_oo.h:518
void SetUrls(wpi::ArrayRef< std::string > urls)
Change the URLs used to connect to the camera.
Definition: cscore_oo.inl:286
void SetDefaultCompression(int quality)
Set the default compression used for non-MJPEG sources.
Definition: cscore_oo.inl:525
std::string GetDescription() const
Get the sink description.
Definition: cscore_oo.inl:463
void SetExposureAuto()
Set the exposure to auto aperature.
Definition: cscore_oo.inl:203
VideoMode GetVideoMode() const
Get the current video mode.
Definition: cscore_oo.inl:129
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
std::string GetPath() const
Get the path to the device.
Definition: cscore_oo.inl:231
A source that represents a video camera.
Definition: cscore_oo.h:271
Kind GetKind() const
Get the kind of the sink.
Definition: cscore_oo.inl:453
void SetEnabled(bool enabled)
Enable or disable getting new frames.
Definition: cscore_oo.inl:560
AxisCamera(wpi::StringRef name, wpi::StringRef host)
Create a source for an Axis IP camera.
Definition: cscore_oo.inl:331
bool SetPixelFormat(VideoMode::PixelFormat pixelFormat)
Set the pixel format.
Definition: cscore_oo.inl:146
VideoSource GetSource() const
Get the source associated with the event (if any).
Definition: cscore_oo.inl:565
void PutFrame(cv::Mat &image)
Put an OpenCV image and notify sinks.
Definition: cscore_oo.inl:359
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:755
VideoProperty GetProperty() const
Get the property associated with the event (if any).
Definition: cscore_oo.inl:575
void SetConnectVerbose(int level)
Set how verbose the camera connection messages are.
Definition: cscore_oo.inl:236
A source that represents an Axis IP camera.
Definition: cscore_oo.h:461
void SetBrightness(int brightness)
Set the brightness, as a percentage (0-100).
Definition: cscore_oo.inl:178
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:835
double GetActualDataRate() const
Get the data rate (in bytes per second).
Definition: cscore_oo.inl:167
uint64_t GetLastFrameTime() const
Get the last time a frame was captured.
Definition: cscore_oo.inl:114
std::string GetListenAddress() const
Get the listen address of the server.
Definition: cscore_oo.inl:497
Video mode.
Definition: cscore_cpp.h:54
void SetWhiteBalanceAuto()
Set the white balance to auto.
Definition: cscore_oo.inl:188
void SetConnected(bool connected)
Set source connection status.
Definition: cscore_oo.inl:369
bool SetVideoMode(const VideoMode &mode)
Set the video mode.
Definition: cscore_oo.inl:134
int GetBrightness()
Get the brightness, as a percentage (0-100).
Definition: cscore_oo.inl:183