现在我使用sws_scale将avframe转换为iplimage,然后使用opencv对图像进行一些操作,然后将iplimage转换为avframe,但图像看起来比原始图像更加紫色。这是我的代码
int av2ipl(AVFrame *src, IplImage *dst, int height, int width)
{
struct SwsContext *swscontext = sws_getContext(width, height, PIX_FMT_YUV420P, dst->width, dst->height, PIX_FMT_BGR24, SWS_BILINEAR, 0, 0, 0);
if (swscontext == 0)
return 0;
int linesize[4] = {dst->widthStep, 0, 0, 0 };
sws_scale(swscontext, src->data, src->linesize, 0, height, (uint8_t **) & (dst->imageData), linesize);
return 1;
}
int ipl2av(IplImage* src, AVFrame* dst, int height, int width)
{
struct SwsContext *swscontext = sws_getContext(width, height, PIX_FMT_BGR24, width, height, PIX_FMT_YUV420P, SWS_BILINEAR, 0, 0, 0);
if(swscontext == 0)
return 0;
int linesize[4] = {src->widthStep, 0, 0, 0};
sws_scale(swscontext, (uint8_t **) & (src->imageData), linesize, 0, height, dst- >data, dst->linesize);
return 1;
}
代码有什么问题吗?