1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
unsigned int Monitor::DetectMotion(uint8_t * sd, Event::StringSet &zoneSet ) {
//std::vector<Coord> vertex_points;
//minimum manhattan distance to consider a motion_vector with displacement
int min_vector_size=1; //FIXME, need to be a config option
//number of vectors clustered together as minimum "filter"
int min_vectors_filter=2; //FIXME, need to be a config option
//minimum manhattan pixel distance between vectors to consider them as belonging together in a cluster
int min_vector_cluster_distance=10; //FIXME, need to be a config option
uint16_t size=0;
int offset=0;
//first 16bit value is size
if (sd) {
uint8_t size8bit[2];
memcpy(&size8bit,sd,2);
size=((uint16_t)size8bit[1] << 8) | size8bit[0];
offset=sizeof(uint16_t);
}
if (size>0) {
for (int i = 0; i < size; i++) {
uint16_t x,y;
uint8_t x8bit[2];
memcpy(&x8bit,sd+offset,2);
x=((uint16_t)x8bit[1] << 8) | x8bit[0];
offset+=2;
uint8_t y8bit[2];
memcpy(&y8bit,sd+offset,2);
y=((uint16_t)y8bit[1] << 8) | y8bit[0];
offset+=2;
//vertex_points[i]=Coord(x,y);
//Info("Vertex %d,%d",vertex_points[i].X(),vertex_points[i].Y() );
//Info("Vertex %d,%d",x,y);
}
//Info("DetectMotion size of vertex %d compared with vector size of %d", size, vertex_points.size());
} else
Info("No mvect data");
//return vertex_points.size();
return size;
}
|