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;
127 uint64_t GetLastFrameTime()
const;
139 std::vector<VideoProperty> EnumerateProperties()
const;
146 bool SetVideoMode(
const VideoMode& mode);
154 bool SetVideoMode(VideoMode::PixelFormat pixelFormat,
int width,
int height,
160 bool SetPixelFormat(VideoMode::PixelFormat pixelFormat);
166 bool SetResolution(
int width,
int height);
171 bool SetFPS(
int fps);
176 double GetActualFPS()
const;
181 double GetActualDataRate()
const;
184 std::vector<VideoMode> EnumerateVideoModes()
const;
186 CS_Status GetLastStatus()
const {
return m_status; }
190 std::vector<VideoSink> EnumerateSinks();
194 static std::vector<VideoSource> EnumerateSources();
198 swap(first.m_status, second.m_status);
199 swap(first.m_handle, second.m_handle);
203 explicit VideoSource(CS_Source handle) : m_handle(handle) {}
205 mutable CS_Status m_status = 0;
214 kFixedOutdoor1 = 4000,
215 kFixedOutdoor2 = 5000,
216 kFixedFluorescent1 = 5100,
217 kFixedFlourescent2 = 5200
223 void SetBrightness(
int brightness);
229 void SetWhiteBalanceAuto();
232 void SetWhiteBalanceHoldCurrent();
235 void SetWhiteBalanceManual(
int value);
238 void SetExposureAuto();
241 void SetExposureHoldCurrent();
244 void SetExposureManual(
int value);
267 static std::vector<UsbCameraInfo> EnumerateUsbCameras();
270 std::string GetPath()
const;
276 enum HttpCameraKind {
277 kUnknown = CS_HTTP_UNKNOWN,
278 kMJPGStreamer = CS_HTTP_MJPGSTREAMER,
279 kCSCore = CS_HTTP_CSCORE,
288 HttpCameraKind kind = kUnknown);
295 HttpCameraKind kind = kUnknown);
302 HttpCameraKind kind = kUnknown);
309 HttpCameraKind kind = kUnknown);
315 template <
typename T>
317 HttpCameraKind kind = kUnknown);
322 HttpCameraKind GetHttpCameraKind()
const;
328 template <
typename T>
329 void SetUrls(std::initializer_list<T> urls);
332 std::vector<std::string> GetUrls()
const;
339 template <
typename T>
340 static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
371 template <
typename T>
392 int height,
int fps);
399 void PutFrame(cv::Mat& image);
407 void SetConnected(
bool connected);
423 int minimum,
int maximum,
int step,
424 int defaultValue,
int value);
435 int maximum,
int step,
int defaultValue,
462 template <
typename T>
464 std::initializer_list<T> choices);
474 kUnknown = CS_SINK_UNKNOWN,
475 kMjpeg = CS_SINK_MJPEG,
485 explicit operator bool()
const {
return m_handle != 0; }
487 int GetHandle()
const {
return m_handle; }
489 bool operator==(
const VideoSink& other)
const {
490 return m_handle == other.m_handle;
493 bool operator!=(
const VideoSink& other)
const {
return !(*
this == other); }
496 Kind GetKind()
const;
500 std::string GetName()
const;
503 std::string GetDescription()
const;
521 CS_Status GetLastStatus()
const {
return m_status; }
525 static std::vector<VideoSink> EnumerateSinks();
529 swap(first.m_status, second.m_status);
530 swap(first.m_handle, second.m_handle);
534 explicit VideoSink(CS_Sink handle) : m_handle(handle) {}
536 mutable CS_Status m_status = 0;
557 std::string GetListenAddress()
const;
594 uint64_t GrabFrame(cv::Mat& image,
double timeout = 0.225)
const;
601 uint64_t GrabFrameNoTimeout(cv::Mat& image)
const;
605 std::string GetError()
const;
611 void SetEnabled(
bool enabled);
639 int eventMask,
bool immediateNotify);
649 swap(first.m_handle, second.m_handle);
653 CS_Listener m_handle;
658 #include "cscore_oo.inl" 660 #endif // CSCORE_CSCORE_OO_H_ Definition: CvSourceImpl.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:468
An event generated by the library and provided to event listeners.
Definition: cscore_oo.h:615
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:71
A source that represents a USB camera.
Definition: cscore_oo.h:251
An event listener.
Definition: cscore_oo.h:629
A source that represents a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.h:274
bool IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
Definition: ntcore_cpp.cpp:904
Definition: cscore_oo.h:30
MjpegServer(wpi::StringRef name, int port)
Create a MJPEG-over-HTTP server sink.
Definition: cscore_oo.h:554
A source for user code to provide OpenCV images as video frames.
Definition: cscore_oo.h:376
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A source that represents a video camera.
Definition: cscore_oo.h:210
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:541
A source that represents an Axis IP camera.
Definition: cscore_oo.h:336
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:564
Video mode.
Definition: cscore_cpp.h:46