2011-10-25 19 views
2

我想知道如何在OpenCV的視頻幀中創建類似發光球或發光線的效果。任何提示,我可以開始或我可以使用什麼,所以我可以在我的輸出中創建簡單的動畫?在OpenCV中動畫我的檢測對象

在此先感謝!

回答

1

這些效果使用原始OpenCV像素操作很容易實現。假設您將球標記爲單獨的蒙版圖像中的白色區域mask。使用GaussianBlur模糊此面具,然後將結果與源圖像img結合。對於發光效果,你可能想要的東西,如Photoshop的屏幕混合模式,這隻會使圖像變亮:

Result Color = 255 - [((255 - Top Color)*(255 - Bottom Color))/255]

的真正關鍵的「發光」效果在底層使用像素層作爲屏幕層。這意味着OpenCV:

cv::Mat mask, img; 
... 
mask = mask * img; //fill the mask region with pixels from the original image 
cv::GaussianBlur(mask, mask, cv::Size(0,0), 4); //blur the mask, 4 pixels radius 
mask = mask * 0.50; //a 50% opacity glow 
img = 255 - ((255 - mask).mul(255 - img)/255); //mul for per-element multiply 

我沒有測試這段代碼,所以我可能在這裏出了問題。色彩減淡也是一種有用的發光混合模式。 更多這裏:How does photoshop blend two images together?