当前位置:网站首页>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];
边栏推荐
- Werewolf killing strategy: do you think I'm easy to cheat? Who do we believe!
- [go ~ 0 to 1] day 5 July 1 type alias, custom type, interface, package and initialization function
- What must be done in graduation season before going to Shanhai
- Specification of lumiprobe reactive dye indocyanine green
- ffmpeg 音频相关命令
- GetMessage底层机制分析
- 从零开始学 MySQL —数据库和数据表操作
- MATLAB中subplot函数的使用
- ffmpeg AVFrame 转 cv::Mat
- [pytorch record] automatic hybrid accuracy training torch cuda. amp
猜你喜欢

Dom4J解析XML、Xpath检索XML

求各种极限的方法
![[to.Net] C set class source code analysis](/img/59/4c7b910bc6505e5f81015ce80812fc.png)
[to.Net] C set class source code analysis

nacos启动失败问题解决与总结

Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits

Dlib+Opencv库实现疲劳检测

Task: denial of service DOS

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

正则表达式=Regex=regular expression
![pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']](/img/98/c4df0747856eda262b82942eedad8f.png)
pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
随机推荐
[6.24-7.1] review of wonderful technical blog posts in the writing community
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
nacos启动失败问题解决与总结
[info() method in org.slf4j.logger]
Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
sql查询去重统计的方法总结
Methods of finding various limits
[to.Net] C set class source code analysis
Parallelism, concurrency and life cycle of threads
241. Different Ways to Add Parentheses
Download (export) PDF template file (such as approval form), and report error: invalid nested tag * * * found, expected closing tag***
XML syntax, constraints
【pytorch记录】自动混合精度训练 torch.cuda.amp
The difference between indexof and includes
The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
Lumiprobe free radical analysis h2dcfda instructions
pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
nacos配置文件发布失败,请检查参数是否正确的解决方案
Nacos configuration file publishing failed, please check whether the parameters are correct solution