资源简介
motion-3.2.11.1.tar.gz 源码 用于视频监控的运动检测 远程监控等
代码片段和文件信息
/* alg.c
*
* Detect changes in a video stream.
* Copyright 2001 by Jeroen Vreeken (pe1rxq@amsat.org)
* This software is distributed under the GNU public license version 2
* See also the file ‘COPYING‘.
*
*/
#include “motion.h“
#include “alg.h“
#ifdef __MMX__
#define HAVE_MMX
#include “mmx.h“
#endif
#define MAX2(x y) ((x) > (y) ? (x) : (y))
#define MAX3(x y z) ((x) > (y) ? ((x) > (z) ? (x) : (z)) : ((y) > (z) ? (y) : (z)))
/* locate the center and size of the movement. */
void alg_locate_center_size(struct images *imgs int width int height struct coord *cent)
{
unsigned char *out = imgs->out;
int *labels = imgs->labels;
int x y centc = 0 xdist = 0 ydist = 0;
cent->x = 0;
cent->y = 0;
cent->maxx = 0;
cent->maxy = 0;
cent->minx = width;
cent->miny = height;
/* If Labeling enabled - locate center of largest labelgroup */
if (imgs->labelsize_max) {
/* Locate largest labelgroup */
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (*(labels++)&32768) {
cent->x += x;
cent->y += y;
centc++;
}
}
}
} else {
/* Locate movement */
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (*(out++)) {
cent->x += x;
cent->y += y;
centc++;
}
}
}
}
if (centc) {
cent->x = cent->x / centc;
cent->y = cent->y / centc;
}
/* Now we find the size of the Motion */
/* First reset pointers back to initial value */
centc = 0;
labels = imgs->labels;
out = imgs->out;
/* If Labeling then we find the area around largest labelgroup instead */
if (imgs->labelsize_max) {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (*(labels++)&32768) {
if (x > cent->x)
xdist += x - cent->x;
else if (x < cent->x)
xdist += cent->x - x;
if (y > cent->y)
ydist += y - cent->y;
else if (y < cent->y)
ydist += cent->y - y;
centc++;
}
}
}
} else {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (*(out++)) {
if (x > cent->x)
xdist += x - cent->x;
else if (x < cent->x)
xdist += cent->x - x;
if (y > cent->y)
ydist += y - cent->y;
else if (y < cent->y)
ydist += cent->y - y;
centc++;
}
}
}
- 上一篇:Modbus主从站仿真程序
- 下一篇:基于STM32F103的4*5矩阵按键
相关资源
- LeapMotion在UE4上的插件
- abaqus子程序 umeshmotion
- umeshmotion子程序汇总
- 添加运动(motion blur)与去运动模糊(
- genymotion 两个插件包for eclipse
- LeapMotion官方开发文档
- Genymotion所有版本模拟器虚拟机ova文件
- Leap_Motion_Core_Assets_ 4.4.0.rar
- genymotion 2.8.1 资源集合(含破解安装文
- Genymotion插件(eclipse离线安装版)
- Factored Conditional Restricted Boltzmann Mach
- Motion Spatial 双流网络Win环境下调试通
- 上位机与SIMOTION之间的tcpip通讯.rar
- 路径规划综述.pptx
评论
共有 条评论