zoukankan      html  css  js  c++  java
  • 基于OpenCV的视频图像组态 (4) :劈裂动画效果

    写在前面

    本系列博客URL:

    http://www.cnblogs.com/drgraph

    http://blog.csdn.net/arwen

    配套软件下载地址:

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

    配套软件含四个可执行文件:DrGraph.exe,YeeVingDriver.exe,YeeVingPlayer.exe,WatchDog.exe

    其中,

    DrGraph.exe为图形博士软件,可进行电路定量分析及其应用。

    YeeVingDriver.exe是双目触控屏的驱动程序,内含键盘鼠标钩子,安装或运行的时候有可能会当成病毒。

    WatchDog.exe是无人值守软件

    YeeVingPlayer.exe是广告播放软件客户端。

    本系列博客是在上述四个软件研发过程中的片面记录,基本上是属于想到哪写到哪的,不系统。主要目的是自己整理归纳一下,并期望与更多朋友交流。

    QQ/微信:282397369

    EMail: drgraph@qq.com

    劈裂效果

    劈裂效果:显示目标区域位置不变,显示内容(原始阵不变,屏蔽阵变化 -> 显示内容变化)

    enum CbwSplitDirection { // 劈裂方向

        csdVertCollapse = 0, // 上下向中央收缩

            csdVertExpand = 1, // 中央向上下展开

            csdHorzCollapse = 2, // 左右向中央收缩

            csdHorzExpand = 3 // 中央向左右展开

        };

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

        cv::Mat& srcMat, TRect displayRect) {

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

            displayRect.bottom - displayRect.top);

        TRect partRect = wholeRect;

        double cx = partRect.right / 2.0, cy = partRect.bottom / 2.0;

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

        bool vertFlag = (effectOptionType <= csdVertExpand);

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

            cy : cx);

        if (csdVertExpand == effectOptionType) { // 上下向中央收缩

            partRect.top = cy - delta;

            partRect.bottom = cy + delta;

        }

        if (csdVertCollapse == effectOptionType) { // 中央向上下展开

            partRect.top = delta;

            partRect.bottom = 2 * cy - delta;

        }

        if (csdHorzExpand == effectOptionType) { // 左右向中央收缩

            partRect.left = cx - delta;

            partRect.right = cx + delta;

        }

        if (csdHorzCollapse == effectOptionType) { // 中央向左右展开

            partRect.left = delta;

            partRect.right = 2 * cx - delta;

        }

        bool expandFlag =

            (csdVertExpand == effectOptionType ||

            csdHorzExpand == effectOptionType);

        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);

                if (!expandFlag)

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

                bool setFlag = (inFlag == expandFlag);

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

            }

        return true;

    }

    结果

  • 相关阅读:
    asp Excel导入数据库
    Excel导出函数
    asp精简checkbox全选代码
    一个操作读写已存在excel 文件的例子
    asp中实现网络打印功能
    asp操作excel 技术总结
    asp初学者常用的代码
    asp连接各种其他数据库 的方法
    asp得到地址栏里"?"以后的字串
    asp判断今天是星期几
  • 原文地址:https://www.cnblogs.com/drgraph/p/7967361.html
Copyright © 2011-2022 走看看