mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
CvSink: Support grayscale images.
Also support 4-channel BGRx images and provide better error reporting on bad images passed to PutFrame.
This commit is contained in:
@@ -77,7 +77,8 @@ enum CS_PixelFormat {
|
||||
CS_PIXFMT_MJPEG,
|
||||
CS_PIXFMT_YUYV,
|
||||
CS_PIXFMT_RGB565,
|
||||
CS_PIXFMT_BGR
|
||||
CS_PIXFMT_BGR,
|
||||
CS_PIXFMT_GRAY
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@@ -49,7 +49,8 @@ struct VideoMode : public CS_VideoMode {
|
||||
kMJPEG = CS_PIXFMT_MJPEG,
|
||||
kYUYV = CS_PIXFMT_YUYV,
|
||||
kRGB565 = CS_PIXFMT_RGB565,
|
||||
kBGR = CS_PIXFMT_BGR
|
||||
kBGR = CS_PIXFMT_BGR,
|
||||
kGray = CS_PIXFMT_GRAY
|
||||
};
|
||||
VideoMode() {
|
||||
pixelFormat = 0;
|
||||
|
||||
@@ -280,8 +280,9 @@ class CvSource : public VideoSource {
|
||||
int height, int fps);
|
||||
|
||||
/// Put an OpenCV image and notify sinks.
|
||||
/// This is identical in behavior to calling PutImage(0, image) followed by
|
||||
/// NotifyFrame().
|
||||
/// Only 8-bit single-channel or 3-channel (with BGR channel order) images
|
||||
/// are supported. If the format, depth or channel order is different, use
|
||||
/// cv::Mat::convertTo() and/or cv::cvtColor() to convert it first.
|
||||
/// @param image OpenCV image
|
||||
void PutFrame(cv::Mat& image);
|
||||
|
||||
@@ -439,6 +440,7 @@ class CvSink : public VideoSink {
|
||||
void SetDescription(llvm::StringRef description);
|
||||
|
||||
/// Wait for the next frame and get the image.
|
||||
/// The provided image will have three 8-bit channels stored in BGR order.
|
||||
/// @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
/// message);
|
||||
uint64_t GrabFrame(cv::Mat& image) const;
|
||||
|
||||
Reference in New Issue
Block a user