使用 OpenCV 消除闪烁?

发布于 2024-10-20 23:31:16 字数 275 浏览 4 评论 0原文

我是 openCV 的新手。我已经在 ubuntu 系统上安装了 opencv 库,对其进行了编译,并尝试研究 opencv 中的一些图像/视频处理应用程序以了解更多信息。

我有兴趣知道 OpenCV 库是否有任何算法/类可以消除捕获视频中的闪烁?如果是,我应该深入研究哪些文档或代码?

如果 openCV 没有它,其他一些视频处理库/SDK/Matlab 中是否有任何标准实现,它们提供了从视频序列中消除闪烁的算法?

任何指示都会有用

谢谢。

-广告。

I am a newbie to openCV. I have installed the opencv library on a ubuntu system, compiled it and trying to look into some image/video processing apps in opencv to understand more.

I am interested to know if OpenCV library has any algorithm/class for removal flicker in captured videos? If yes what document or code should I should look deeper into?

If openCV does not have it, are there any standard implementations in some other Video processing library/SDK/Matlab,.. which provide algorithms for flicker removal from video sequences?

Any pointers would be useful

Thank you.

-AD.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拍不死你 2024-10-27 23:31:16

我不知道任何消除视频闪烁的标准方法。

但是 VirtualDub 是一款视频处理软件,它具有用于消除视频闪烁的过滤器。您可以在此处找到它的过滤器源代码和文档(可能是算法描述)。

I don't know any standard way to deflicker a video.

But VirtualDub is a Video Processing software which has a Filter for deflickering the video. You can find it's filter source and documents (algorithm description probably) here.

愛放△進行李 2024-10-27 23:31:16

我编写了自己的 Deflicker C++ 函数。这里是。您可以按原样剪切并粘贴此代码 - 除了通常的 openCV 之外不需要标头。

    Mat deflicker(Mat,int);
    Mat prevdeflicker;
    Mat deflicker(Mat Mat1,int strengthcutoff = 20){  //deflicker - compares each pixel of the frame to a previously stored frame, and throttle small changes in pixels (flicker)

    if (prevdeflicker.rows){//check if we stored a previous frame of this name.//if not, theres nothing we can do. clone and exit
         int i,j;
        uchar* p;
        uchar* prevp;
        for( i = 0; i < Mat1.rows; ++i)
        {
            p = Mat1.ptr<uchar>(i);
            prevp = prevdeflicker.ptr<uchar>(i);
            for ( j = 0; j < Mat1.cols; ++j){  

                Scalar previntensity = prevp[j];
                Scalar intensity = p[j];
                int strength = abs(intensity.val[0] - previntensity.val[0]);

                if(strength < strengthcutoff){ //the strength of the stimulus must be greater than a certain point, else we do not want to allow the change
                    //value 25 works good for medium+ light.  anything higher creates too much blur around moving objects. 
                    //in low light however this makes it worse, since low light seems to increase contrasts in flicker - some flickers go from 0 to 255 and back.  :(
                    //I need to write a way to track large group movements vs small pixels, and only filter out the small pixel stuff.  maybe blur first?

                    if(intensity.val[0] > previntensity.val[0]){  // use the previous frames value.  Change it by +1 - slow enough to not be noticable flicker
                        p[j] = previntensity.val[0] + 1;  
                    }else{
                        p[j] = previntensity.val[0] - 1;
                    }
                }

            }

        }//end for
    }

    prevdeflicker = Mat1.clone();//clone the current one as the old one.
    return Mat1;
}

称其为:Mat= deflicker(Mat)。它需要一个循环和一个灰度图像,如下所示:

for(;;){
    cap >> frame; // get a new frame from camera
    cvtColor( frame, src_grey, CV_RGB2GRAY );  //convert to greyscale - simplifies everything

    src_grey = deflicker(src_grey);  // this is the function call

    imshow("grey video", src_grey);
    if(waitKey(30) >= 0) break;
}

I wrote my own Deflicker C++ function. here it is. You can cut and paste this code as is - no headers needed other than the usual openCV ones.

    Mat deflicker(Mat,int);
    Mat prevdeflicker;
    Mat deflicker(Mat Mat1,int strengthcutoff = 20){  //deflicker - compares each pixel of the frame to a previously stored frame, and throttle small changes in pixels (flicker)

    if (prevdeflicker.rows){//check if we stored a previous frame of this name.//if not, theres nothing we can do. clone and exit
         int i,j;
        uchar* p;
        uchar* prevp;
        for( i = 0; i < Mat1.rows; ++i)
        {
            p = Mat1.ptr<uchar>(i);
            prevp = prevdeflicker.ptr<uchar>(i);
            for ( j = 0; j < Mat1.cols; ++j){  

                Scalar previntensity = prevp[j];
                Scalar intensity = p[j];
                int strength = abs(intensity.val[0] - previntensity.val[0]);

                if(strength < strengthcutoff){ //the strength of the stimulus must be greater than a certain point, else we do not want to allow the change
                    //value 25 works good for medium+ light.  anything higher creates too much blur around moving objects. 
                    //in low light however this makes it worse, since low light seems to increase contrasts in flicker - some flickers go from 0 to 255 and back.  :(
                    //I need to write a way to track large group movements vs small pixels, and only filter out the small pixel stuff.  maybe blur first?

                    if(intensity.val[0] > previntensity.val[0]){  // use the previous frames value.  Change it by +1 - slow enough to not be noticable flicker
                        p[j] = previntensity.val[0] + 1;  
                    }else{
                        p[j] = previntensity.val[0] - 1;
                    }
                }

            }

        }//end for
    }

    prevdeflicker = Mat1.clone();//clone the current one as the old one.
    return Mat1;
}

Call it as: Mat= deflicker(Mat). It needs a loop, and a greyscale image, like so:

for(;;){
    cap >> frame; // get a new frame from camera
    cvtColor( frame, src_grey, CV_RGB2GRAY );  //convert to greyscale - simplifies everything

    src_grey = deflicker(src_grey);  // this is the function call

    imshow("grey video", src_grey);
    if(waitKey(30) >= 0) break;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文