当前位置:网站首页>ffmpeg AVFrame 转 cv::Mat
ffmpeg AVFrame 转 cv::Mat
2022-07-01 18:45:00 【lcyw】
//AVFrame 转 cv::mat
cv::Mat frame_to_mat(const AVFrame * frame) {
int width = frame->width;
int height = frame->height;
cv::Mat image(height, width, CV_8UC3);
int cvLinesizes[1];
cvLinesizes[0] = image.step1();
if( NULL == _swsContext) {
_swsContext = sws_getContext(width, height,
(AVPixelFormat)frame->format, width, height,
AVPixelFormat::AV_PIX_FMT_BGR24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
}
sws_scale(_swsContext, frame->data,
frame->linesize, 0, height, &image.data, cvLinesizes);
return image;
}
上面函数传入的参数frame中的图像格式,可以是YUV, RGB ,等等,,
经过sws_scale()转换之后,写入cv::Mat 数据区。
还有一种方式 是直接将AVFrame 中的RGB数据赋值给cv::Mat
cv::Mat img;
img = cv::Mat(height, width, CV_8UC3);
img.data = _rgb_frame->data[0];
边栏推荐
- 正则表达式=Regex=regular expression
- The use of subplot function in MATLAB
- 论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
- Lake shore optimag superconducting magnet system om series
- How to redraw the header of CListCtrl in MFC
- 【Go ~ 0到1 】 第四天 6月30 defer,结构体,方法
- Lake shore M91 fast hall measuring instrument
- Superoptimag superconducting magnet system - SOM, Som2 series
- Lake Shore continuous flow cryostat transmission line
- Go语言高级
猜你喜欢

混沌工程平台 ChaosBlade-Box 新版重磅发布

Facebook聊单,SaleSmartly有妙招!

有关 M91 快速霍尔测量仪的更多信息
![Reading the paper [learning to discretely compose reasoning module networks for video captioning]](/img/a2/acdaebeb67ec4bcb01c8ff4bbd1d1e.png)
Reading the paper [learning to discretely compose reasoning module networks for video captioning]

Helium transmission line of lake shore cryostat

Enabling "new Chinese enterprises", SAP process automation landing in China

How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?

Lumiprobe free radical analysis h2dcfda instructions

精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
![[to.Net] C set class source code analysis](/img/59/4c7b910bc6505e5f81015ce80812fc.png)
[to.Net] C set class source code analysis
随机推荐
Helium transmission line of lake shore cryostat
论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
商业智能BI开发和报表开发有什么本质区别?
Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
Dom4J解析XML、Xpath检索XML
从零开始学 MySQL —数据库和数据表操作
狼人杀攻略:你当我好骗吗,我们相信谁!
axure不显示元件库
求各种极限的方法
transform + asm资料
Lake Shore—OptiMag 超导磁体系统 — OM 系列
M91 fast hall measuring instrument - better measurement in a shorter time
【英语语法】Unit1 冠词、名词、代词和数词
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
Specification of lumiprobe reactive dye indocyanine green
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
PostgreSQL varchar[] 数组类型操作
The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables