8 #ifndef CSCORE_IMAGE_H_ 9 #define CSCORE_IMAGE_H_ 13 #include <llvm/StringRef.h> 14 #include <opencv2/core/core.hpp> 16 #include "cscore_cpp.h" 17 #include "default_init_allocator.h" 28 explicit Image(
size_t capacity) { m_data.reserve(capacity); }
30 explicit Image(
size_t capacity)
42 size_t capacity()
const {
return m_data.capacity(); }
43 const char* data()
const {
44 return reinterpret_cast<const char*
>(m_data.data());
46 char* data() {
return reinterpret_cast<char*
>(m_data.data()); }
47 size_t size()
const {
return m_data.size(); }
49 const std::vector<uchar>& vec()
const {
return m_data; }
50 std::vector<uchar>& vec() {
return m_data; }
52 void resize(
size_t size) { m_data.resize(size); }
53 void SetSize(
size_t size) { m_data.resize(size); }
57 switch (pixelFormat) {
58 case VideoMode::kYUYV:
59 case VideoMode::kRGB565:
65 case VideoMode::kGray:
66 case VideoMode::kMJPEG:
71 return cv::Mat{height, width, type, m_data.data()};
74 cv::_InputArray AsInputArray() {
return cv::_InputArray{m_data}; }
76 bool Is(
int width_,
int height_) {
77 return width == width_ && height == height_;
79 bool Is(
int width_,
int height_, VideoMode::PixelFormat pixelFormat_) {
80 return width == width_ && height == height_ && pixelFormat == pixelFormat_;
82 bool IsLarger(
int width_,
int height_) {
83 return width >= width_ && height >= height_;
85 bool IsLarger(
const Image& oth) {
86 return width >= oth.width && height >= oth.height;
88 bool IsSmaller(
int width_,
int height_) {
return !IsLarger(width_, height_); }
89 bool IsSmaller(
const Image& oth) {
return !IsLarger(oth); }
92 std::vector<uchar> m_data;
95 VideoMode::PixelFormat pixelFormat{VideoMode::kUnknown};
102 #endif // CSCORE_IMAGE_H_ Definition: SinkImpl.h:19
Definition: default_init_allocator.h:16
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42