基於OpenCV的視頻圖像組態 (5) :擦除動畫效果

寫在前面 c++

本系列博客URL:微信

http://www.cnblogs.com/drgraphui

http://blog.csdn.net/arwenspa

配套軟件下載地址:.net

http://www.czwenwu.com/YeeVingSetup.exeblog

配套軟件含四個可執行文件:DrGraph.exe,YeeVingDriver.exe,YeeVingPlayer.exe,WatchDog.exeget

其中,博客

DrGraph.exe爲圖形博士軟件,可進行電路定量分析及其應用。it

YeeVingDriver.exe是雙目觸控屏的驅動程序,內含鍵盤鼠標鉤子,安裝或運行的時候有可能會當成病毒。io

WatchDog.exe是無人值守軟件

YeeVingPlayer.exe是廣告播放軟件客戶端。

本系列博客是在上述四個軟件研發過程當中的片面記錄,基本上是屬於想到哪寫到哪的,不繫統。主要目的是本身整理概括一下,並指望與更多朋友交流。

QQ/微信:282397369

EMail: drgraph@qq.com

 

擦除效果

擦除效果:顯示目標區域位置不變,顯示內容(原始陣不變,屏蔽陣變化 -> 顯示內容變化)

 

bool __fastcall TCbwAnimationEffect_Erase::BuildMaskMat(cv::Mat& destMat,

    cv::Mat& srcMat, TRect displayRect) {

    int effectOptionType = MyOptionType.Items[1].CurrentValue * 2;

    TRect wholeRect(0, 0, displayRect.right - displayRect.left,

        displayRect.bottom - displayRect.top);

    TRect partRect = wholeRect;

    bool vertFlag =

        (cedFromBottom == effectOptionType || cedFromTop == effectOptionType);

    double delta = double(FCurrentIndex + 1) / FTotalFramesInOnePeriod * (vertFlag ?

        partRect.bottom : partRect.right);

    if (cedFromBottom == effectOptionType) // 自底部

            partRect.top = partRect.bottom - delta;

    if (cedFromLeft == effectOptionType) // 自左側

            partRect.right = partRect.left + delta;

    if (cedFromTop == effectOptionType) // 自頂部

            partRect.bottom = partRect.top + delta;

    if (cedFromRight == effectOptionType) // 自右側

            partRect.left = partRect.right - delta;

    BYTE * pSrc = srcMat.data;

    BYTE * pDst = destMat.data;

    for (int row = 0; row < destMat.rows; ++row)

        for (int col = 0; col < destMat.cols; ++col) {

            bool hasValueFlag = (*pSrc++ != 0);

            if (!hasValueFlag)

                * pDst = 0;

            int y = (row - partRect.top) * (partRect.bottom - row);

            int x = (col - partRect.left) * (partRect.right - col);

            bool inFlag = (y >= 0 && x >= 0);

            *pDst++ = (inFlag ? 255 : 0);

        }

    return true;

}

 

演示效果

 

相關文章
相關標籤/搜索