Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv iplimage与avframe的转换_Opencv_Ffmpeg - Fatal编程技术网

Opencv iplimage与avframe的转换

Opencv iplimage与avframe的转换,opencv,ffmpeg,Opencv,Ffmpeg,现在我使用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

现在我使用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;
}

代码中有错误吗?

您可以发布示例图像吗?