#ifndef __cplusplus
#error "ccap_opencv.h is for C++ only. For C language, please use ccap_c.h instead."
#endif
#pragma once
#ifndef CCAP_OPENCV_H
#define CCAP_OPENCV_H
#include "ccap_core.h"
#include <memory>
#include <opencv2/core.hpp>
namespace ccap
{
inline cv::Mat convertRgbFrameToMat(const VideoFrame& frame)
{
if (!((uint32_t)frame.pixelFormat & (uint32_t)kPixelFormatRGBColorBit))
{
return {};
}
auto typeEnum = (uint32_t)frame.pixelFormat & (uint32_t)kPixelFormatAlphaColorBit ? CV_8UC4 : CV_8UC3;
return cv::Mat(frame.height, frame.width, typeEnum, frame.data[0], frame.stride[0]);
}
}
#endif