当前位置:网站首页>Ffmpeg avframe to cv:: mat
Ffmpeg avframe to cv:: mat
2022-07-01 19:34:00 【lcyw】
//AVFrame turn 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;
}
The parameters passed in by the above function frame Image format in , It can be YUV, RGB , wait ,,
after sws_scale() After the transformation , write in cv::Mat Data area .
There's another way Is directly to the AVFrame Medium RGB The data is assigned to cv::Mat
cv::Mat img;
img = cv::Mat(height, width, CV_8UC3);
img.data = _rgb_frame->data[0];
边栏推荐
- 寶,運維100+服務器很頭疼怎麼辦?用行雲管家!
- win10下使用msys+vs2019编译ffmpeg源码
- Once the SQL is optimized, the database query speed is increased by 60 times
- 【6.24-7.1】写作社区精彩技术博文回顾
- 【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
- Flutter 实战-快速实现音视频通话应用
- H264编码profile & level控制
- Transform + ASM data
- Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
- [6.24-7.1] review of wonderful technical blog posts in the writing community
猜你喜欢

商业智能BI开发和报表开发有什么本质区别?

sql查询去重统计的方法总结

Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation

Detailed explanation of JUnit unit test framework

optaplanner学习笔记(一)案例Cloud balance

Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?

Dlib+Opencv库实现疲劳检测

uni-app微信小程序一键登录获取权限功能

Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!

GB28181之SIP协议
随机推荐
indexof和includes的区别
大厂音视频职位面试题目--今日头条
Contos 7 搭建sftp之创建用户、用户组以及删除用户
Implement a Prometheus exporter
Ubuntu14 install MySQL and configure root account local and remote access
见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
Team up to learn! 14 days of Hongmeng equipment development "learning, practicing and testing" practical camp, free of charge!
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
Detailed explanation of JUnit unit test framework
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
English语法_形容词/副词3级 -注意事项
奔赴山海之前,毕业季一定要做的那些事情
Lumiprobe phosphide hexaethylene phosphide specification
Learning notes - steps of JDBC connection database operation
MFC中如何重绘CListCtrl的表头
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
What must be done in graduation season before going to Shanhai
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference