我是openCV的新手。我已經在ubuntu系統上安裝了opencv庫,對它進行了編譯並嘗試在opencv中查看一些圖像/視頻處理應用程序以瞭解更多信息。使用OpenCV消除閃爍?
我很想知道OpenCV庫是否有捕獲視頻中的閃爍算法/類?如果是的話,我應該更深入地研究哪些文件或代碼?
如果openCV沒有它,在其他一些視頻處理庫/ SDK/Matlab中是否有任何標準實現,它們提供了從視頻序列中去除閃爍的算法?
任何指針都會有用
謝謝。
-AD。
我是openCV的新手。我已經在ubuntu系統上安裝了opencv庫,對它進行了編譯並嘗試在opencv中查看一些圖像/視頻處理應用程序以瞭解更多信息。使用OpenCV消除閃爍?
我很想知道OpenCV庫是否有捕獲視頻中的閃爍算法/類?如果是的話,我應該更深入地研究哪些文件或代碼?
如果openCV沒有它,在其他一些視頻處理庫/ SDK/Matlab中是否有任何標準實現,它們提供了從視頻序列中去除閃爍的算法?
任何指針都會有用
謝謝。
-AD。
我不知道任何標準的方法來使視頻閃爍。
但VirtualDub是一個視頻處理軟件,它有一個用於deflickering視頻的過濾器。你可以找到它的過濾源和文檔(可能是算法描述)here。
我寫了我自己的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;
}
感謝您的好指針! +1 – goldenmean 2011-03-08 12:02:38