您的位置:首页 > 运维架构

基于OpenCV的视频图像组态 (4) :劈裂动画效果

2017-12-03 21:17 603 查看
写在前面

本系列博客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;

}

结果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: