5#ifndef CSCORE_CSCORE_RAW_CV_H_
6#define CSCORE_CSCORE_RAW_CV_H_
8#ifdef CSCORE_CSCORE_CV_H_
9#error "Cannot include both cscore_cv.h and cscore_raw_cv.h in the same file"
12#include <opencv2/core/mat.hpp>
49 int width,
int height,
int fps);
103 std::function<
void(
uint64_t time)> processFrame);
136 double timeout = 0.225);
153 : RawSource{name, mode} {}
158 : RawSource{name,
format, width, height,
fps} {}
162 rawFrame.data =
reinterpret_cast<char*
>(image.data);
163 rawFrame.width = image.cols;
164 rawFrame.height = image.rows;
165 rawFrame.totalData = image.total() * image.channels();
167 PutSourceFrame(m_handle, rawFrame, &m_status);
173 std::function<
void(
uint64_t time)> processFrame)
174 : RawSink{name, processFrame} {}
182 tmpnam.copyTo(image);
192 tmpnam.copyTo(image);
200 m_status = RawSink::GrabFrame(rawFrame, timeout);
204 image = cv::Mat{rawFrame.height, rawFrame.width, CV_8UC3, rawFrame.data};
212 m_status = RawSink::GrabFrameNoTimeout(rawFrame);
216 image = cv::Mat{rawFrame.height, rawFrame.width, CV_8UC3, rawFrame.data};
A sink for user code to accept raw video frames as OpenCV images.
Definition: cscore_raw_cv.h:76
uint64_t GrabFrameNoTimeout(cv::Mat &image)
Wait for the next frame and get the image.
Definition: cscore_raw_cv.h:186
uint64_t GrabFrameNoTimeoutDirect(cv::Mat &image)
Wait for the next frame and get the image.
Definition: cscore_raw_cv.h:208
uint64_t GrabFrameDirect(cv::Mat &image, double timeout=0.225)
Wait for the next frame and get the image.
Definition: cscore_raw_cv.h:196
uint64_t GrabFrame(cv::Mat &image, double timeout=0.225)
Wait for the next frame and get the image.
Definition: cscore_raw_cv.h:176
A source for using the raw frame API to provide opencv images.
Definition: cscore_raw_cv.h:27
void PutFrame(cv::Mat &image)
Put an OpenCV image and notify sinks.
Definition: cscore_raw_cv.h:160
basic_string_view< char > string_view
Definition: core.h:520
@ CS_PIXFMT_BGR
Definition: cscore_c.h:95
@ CS_PIXFMT_GRAY
Definition: cscore_c.h:96
::uint64_t uint64_t
Definition: Meta.h:58
CameraServer (cscore) namespace.
Definition: cscore_cpp.h:31
fps
Definition: velocity.h:46
Video mode.
Definition: cscore_cpp.h:64
PixelFormat
Definition: cscore_cpp.h:65
auto format(wformat_string< T... > fmt, T &&... args) -> std::wstring
Definition: xchar.h:87