RGB后的图像变为垂直线 - > YUV420回到 - > RGB转换 [英] image becomes vertical lines after RGB -> YUV420 back to -> RGB conversion
本文介绍了RGB后的图像变为垂直线 - > YUV420回到 - > RGB转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个RGB24图像,我保存在文件中,我使用sws_scale将其转换为YUV420然后我想验证转换是否正确完成我尝试将其转换回RGB24以查看结果。而我所看到的只是垂直的白色和黑色条纹。我做错了什么?
任何帮助都将不胜感激!
我附上了代码这里
Hi
I have a RGB24 image which I am saved on file, I am using sws_scale to convert it to YUV420 and then I wanted to verify if the conversion was done correctly so I tried converting it back to RGB24 to view the results. And all I see is vertical white and black bars. What am I doint incorrect?
Any help would be greatly appreciated!
I have attached the code here
if (sws_ctx == NULL)
{
sws_ctx = sws_getContext(pFrameRGB->width, pFrameRGB->height,
AV_PIX_FMT_RGB24, pFrameRGB->width, pFrameRGB->height,
AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);
}
int inLinesize[1] = { 3*pFrameRGB->width }; // RGB stride
sws_scale(sws_ctx, pFrameRGB->data, inLinesize, 0, pFrameRGB->height, frame2->data, frame2->linesize);
if ( final_sws_ctx == NULL )
{
final_sws_ctx = sws_getContext(pFrameRGB->width, pFrameRGB->height,
AV_PIX_FMT_YUV420P, pFrameRGB->width, pFrameRGB->height,
AV_PIX_FMT_RGB24, SWS_FAST_BILINEAR, 0, 0, 0);
}
sws_scale(sws_ctx, frame2->data, frame2->linesize, 0, frame2->height, finalRGB->data, finalRGB->linesize);
推荐答案
至少,你有错误的错误
At least, you have wrong typo at
sws_scale(sws_ctx, frame2->data, ..)
您需要更改它要
You need to change it to
sws_scale(final_sws_ctx, frame2->data, ..)
这篇关于RGB后的图像变为垂直线 - > YUV420回到 - > RGB转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文