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);
174 std::vector<VideoMode> EnumerateVideoModes()
const;
176 CS_Status GetLastStatus()
const {
return m_status; }
180 std::vector<VideoSink> EnumerateSinks();
184 static std::vector<VideoSource> EnumerateSources();
188 swap(first.m_status, second.m_status);
189 swap(first.m_handle, second.m_handle);
193 explicit VideoSource(CS_Source handle) : m_handle(handle) {}
195 mutable CS_Status m_status = 0;
204 kFixedOutdoor1 = 4000,
205 kFixedOutdoor2 = 5000,
206 kFixedFluorescent1 = 5100,
207 kFixedFlourescent2 = 5200
213 void SetBrightness(
int brightness);
219 void SetWhiteBalanceAuto();
222 void SetWhiteBalanceHoldCurrent();
225 void SetWhiteBalanceManual(
int value);
228 void SetExposureAuto();
231 void SetExposureHoldCurrent();
234 void SetExposureManual(
int value);
257 static std::vector<UsbCameraInfo> EnumerateUsbCameras();
260 std::string GetPath()
const;
266 enum HttpCameraKind {
267 kUnknown = CS_HTTP_UNKNOWN,
268 kMJPGStreamer = CS_HTTP_MJPGSTREAMER,
269 kCSCore = CS_HTTP_CSCORE,
278 HttpCameraKind kind = kUnknown);
285 HttpCameraKind kind = kUnknown);
292 HttpCameraKind kind = kUnknown);
299 HttpCameraKind kind = kUnknown);
305 template <
typename T>
307 HttpCameraKind kind = kUnknown);
312 HttpCameraKind GetHttpCameraKind()
const;
318 template <
typename T>
319 void SetUrls(std::initializer_list<T> urls);
322 std::vector<std::string> GetUrls()
const;
329 template <
typename T>
330 static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
361 template <
typename T>
382 int height,
int fps);
389 void PutFrame(cv::Mat& image);
397 void SetConnected(
bool connected);
413 int minimum,
int maximum,
int step,
414 int defaultValue,
int value);
425 int maximum,
int step,
int defaultValue,
453 template <
typename T>
455 std::initializer_list<T> choices);
465 kUnknown = CS_SINK_UNKNOWN,
466 kMjpeg = CS_SINK_MJPEG,
476 explicit operator bool()
const {
return m_handle != 0; }
478 int GetHandle()
const {
return m_handle; }
480 bool operator==(
const VideoSink& other)
const {
481 return m_handle == other.m_handle;
484 bool operator!=(
const VideoSink& other)
const {
return !(*
this == other); }
487 Kind GetKind()
const;
491 std::string GetName()
const;
494 std::string GetDescription()
const;
512 CS_Status GetLastStatus()
const {
return m_status; }
516 static std::vector<VideoSink> EnumerateSinks();
520 swap(first.m_status, second.m_status);
521 swap(first.m_handle, second.m_handle);
525 explicit VideoSink(CS_Sink handle) : m_handle(handle) {}
527 mutable CS_Status m_status = 0;
548 std::string GetListenAddress()
const;
585 uint64_t GrabFrame(cv::Mat& image,
double timeout = 0.225)
const;
592 uint64_t GrabFrameNoTimeout(cv::Mat& image)
const;
596 std::string GetError()
const;
602 void SetEnabled(
bool enabled);
630 int eventMask,
bool immediateNotify);
640 swap(first.m_handle, second.m_handle);
644 CS_Listener m_handle;
649 #include "cscore_oo.inl" 651 #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:459
An event generated by the library and provided to event listeners.
Definition: cscore_oo.h:606
Listener event.
Definition: cscore_cpp.h:71
A source that represents a USB camera.
Definition: cscore_oo.h:241
An event listener.
Definition: cscore_oo.h:620
A source that represents a MJPEG-over-HTTP (IP) camera.
Definition: cscore_oo.h:264
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:904
Definition: cscore_oo.h:30
A source for user code to provide OpenCV images as video frames.
Definition: cscore_oo.h:366
MjpegServer(llvm::StringRef name, int port)
Create a MJPEG-over-HTTP server sink.
Definition: cscore_oo.h:545
A source that represents a video camera.
Definition: cscore_oo.h:200
A sink that acts as a MJPEG-over-HTTP network server.
Definition: cscore_oo.h:532
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:326
A sink for user code to accept video frames as OpenCV images.
Definition: cscore_oo.h:555
Video mode.
Definition: cscore_cpp.h:46