8 #ifndef CSCORE_CSCORE_OO_H_ 9 #define CSCORE_CSCORE_OO_H_ 11 #include <initializer_list> 16 #include "cscore_cpp.h" 39 kBoolean = CS_PROP_BOOLEAN,
40 kInteger = CS_PROP_INTEGER,
41 kString = CS_PROP_STRING,
47 std::string GetName()
const;
49 Kind GetKind()
const {
return m_kind; }
51 explicit operator bool()
const {
return m_kind != kNone; }
54 bool IsBoolean()
const {
return m_kind == kBoolean; }
55 bool IsInteger()
const {
return m_kind == kInteger; }
56 bool IsString()
const {
return m_kind == kString; }
57 bool IsEnum()
const {
return m_kind == kEnum; }
64 int GetDefault()
const;
67 std::string GetString()
const;
72 std::vector<std::string> GetChoices()
const;
74 CS_Status GetLastStatus()
const {
return m_status; }
80 mutable CS_Status m_status;
92 kUnknown = CS_SOURCE_UNKNOWN,
94 kHttp = CS_SOURCE_HTTP,
104 explicit operator bool()
const {
return m_handle != 0; }
106 int GetHandle()
const {
return m_handle; }
109 return m_handle == other.m_handle;
112 bool operator!=(
const VideoSource& other)
const {
return !(*
this == other); }
115 Kind GetKind()
const;
119 std::string GetName()
const;
122 std::string GetDescription()
const;
125 uint64_t GetLastFrameTime()
const;
137 std::vector<VideoProperty> EnumerateProperties()
const;
144 bool SetVideoMode(
const VideoMode& mode);
152 bool SetVideoMode(VideoMode::PixelFormat pixelFormat,
int width,
int height,
158 bool SetPixelFormat(VideoMode::PixelFormat pixelFormat);
164 bool SetResolution(
int width,
int height);
169 bool SetFPS(
int fps);
172 std::vector<VideoMode> EnumerateVideoModes()
const;
174 CS_Status GetLastStatus()
const {
return m_status; }
178 std::vector<VideoSink> EnumerateSinks();
182 static std::vector<VideoSource> EnumerateSources();
186 swap(first.m_status, second.m_status);
187 swap(first.m_handle, second.m_handle);
191 explicit VideoSource(CS_Source handle) : m_handle(handle) {}
193 mutable CS_Status m_status = 0;
202 kFixedOutdoor1 = 4000,
203 kFixedOutdoor2 = 5000,
204 kFixedFluorescent1 = 5100,
205 kFixedFlourescent2 = 5200
211 void SetBrightness(
int brightness);
217 void SetWhiteBalanceAuto();
220 void SetWhiteBalanceHoldCurrent();
223 void SetWhiteBalanceManual(
int value);
226 void SetExposureAuto();
229 void SetExposureHoldCurrent();
232 void SetExposureManual(
int value);
255 static std::vector<UsbCameraInfo> EnumerateUsbCameras();
258 std::string GetPath()
const;
264 enum HttpCameraKind {
265 kUnknown = CS_HTTP_UNKNOWN,
266 kMJPGStreamer = CS_HTTP_MJPGSTREAMER,
267 kCSCore = CS_HTTP_CSCORE,
276 HttpCameraKind kind = kUnknown);
283 HttpCameraKind kind = kUnknown);
290 HttpCameraKind kind = kUnknown);
297 HttpCameraKind kind = kUnknown);
303 template <
typename T>
305 HttpCameraKind kind = kUnknown);
310 HttpCameraKind GetHttpCameraKind()
const;
316 template <
typename T>
317 void SetUrls(std::initializer_list<T> urls);
320 std::vector<std::string> GetUrls()
const;
327 template <
typename T>
328 static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
359 template <
typename T>
380 int height,
int fps);
387 void PutFrame(cv::Mat& image);
395 void SetConnected(
bool connected);
411 int minimum,
int maximum,
int step,
412 int defaultValue,
int value);
423 int maximum,
int step,
int defaultValue,
451 template <
typename T>
453 std::initializer_list<T> choices);
463 kUnknown = CS_SINK_UNKNOWN,
464 kMjpeg = CS_SINK_MJPEG,
474 explicit operator bool()
const {
return m_handle != 0; }
476 int GetHandle()
const {
return m_handle; }
478 bool operator==(
const VideoSink& other)
const {
479 return m_handle == other.m_handle;
482 bool operator!=(
const VideoSink& other)
const {
return !(*
this == other); }
485 Kind GetKind()
const;
489 std::string GetName()
const;
492 std::string GetDescription()
const;
510 CS_Status GetLastStatus()
const {
return m_status; }
514 static std::vector<VideoSink> EnumerateSinks();
518 swap(first.m_status, second.m_status);
519 swap(first.m_handle, second.m_handle);
523 explicit VideoSink(CS_Sink handle) : m_handle(handle) {}
525 mutable CS_Status m_status = 0;
546 std::string GetListenAddress()
const;
582 uint64_t GrabFrame(cv::Mat& image,
double timeout = 0.225)
const;
588 uint64_t GrabFrameNoTimeout(cv::Mat& image)
const;
592 std::string GetError()
const;
598 void SetEnabled(
bool enabled);
626 int eventMask,
bool immediateNotify);
636 swap(first.m_handle, second.m_handle);
640 CS_Listener m_handle;
645 #include "cscore_oo.inl" 647 #endif // CSCORE_CSCORE_OO_H_ Definition: SinkImpl.h:19
A source for video that provides a sequence of frames.
Definition: cscore_oo.h:86
A sink for video that accepts a sequence of frames.
Definition: cscore_oo.h:457
An event generated by the library and provided to event listeners.
Definition: cscore_oo.h:602
Listener event.
Definition: cscore_cpp.h:71
A source that represents a USB camera.
Definition: cscore_oo.h:239
An event listener.
Definition: cscore_oo.h:616
A source that represents a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.h:262
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:32
bool IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
Definition: ntcore_cpp.cpp:902
Definition: cscore_oo.h:30
A source for user code to provide OpenCV images as video frames.
Definition: cscore_oo.h:364
MjpegServer(llvm::StringRef name, int port)
Create a MJPEG-over-HTTP server sink.
Definition: cscore_oo.h:543
A source that represents a video camera.
Definition: cscore_oo.h:198
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:530
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42
A source that represents an Axis IP camera.
Definition: cscore_oo.h:324
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:553
Video mode.
Definition: cscore_cpp.h:46