当前位置:网站首页>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];
边栏推荐
- 微信公众号开发相关流程及功能介绍
- ddr4测试-2
- [info() method in org.slf4j.logger]
- Shell高级进阶
- The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
- 有关 M91 快速霍尔测量仪的更多信息
- Lake Shore M91快速霍尔测量仪
- uni-app微信小程序一键登录获取权限功能
- Dlib+Opencv库实现疲劳检测
- Lake shore M91 fast hall measuring instrument
猜你喜欢

M91 fast hall measuring instrument - better measurement in a shorter time

Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework

Facebook聊单,SaleSmartly有妙招!

Shell高级进阶

白盒加密技术浅理解

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

Helium transmission line of lake shore cryostat

Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性

Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit

Dom4j parsing XML, XPath retrieving XML
随机推荐
Lake shore optimag superconducting magnet system om series
Dom4j parsing XML, XPath retrieving XML
宝,运维100+服务器很头疼怎么办?用行云管家!
ddr4测试-2
Reading the paper [learning to discretely compose reasoning module networks for video captioning]
PostgreSQL varchar[] array type operation
【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
正则表达式=Regex=regular expression
The difference between indexof and includes
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
Dlib+opencv library for fatigue detection
Chaos engineering platform chaosblade box new heavy release
学习笔记-JDBC连接数据库操作的步骤
实现一个Prometheus exporter
English grammar_ Adjective / adverb Level 3 - precautions
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
MFC中如何重绘CListCtrl的表头
奔赴山海之前,毕业季一定要做的那些事情
商业智能BI开发和报表开发有什么本质区别?
Nacos configuration file publishing failed, please check whether the parameters are correct solution