Renamed variables and added blob overflow code.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1540 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
351f6c9491
commit
af85fd6916
|
@ -214,9 +214,10 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
||||||
BlobStats blob_stats[256];
|
BlobStats blob_stats[256];
|
||||||
memset( blob_stats, 0, sizeof(BlobStats)*256 );
|
memset( blob_stats, 0, sizeof(BlobStats)*256 );
|
||||||
unsigned char *pdiff, *spdiff;
|
unsigned char *pdiff, *spdiff;
|
||||||
int lx, ly;
|
int last_x, last_y;
|
||||||
BlobStats *bsx, *bsy;
|
BlobStats *bsx, *bsy;
|
||||||
BlobStats *bsm, *bss;
|
BlobStats *bsm, *bss;
|
||||||
|
int diff_width = diff_image->Width();
|
||||||
for ( int y = lo_y; y <= hi_y; y++ )
|
for ( int y = lo_y; y <= hi_y; y++ )
|
||||||
{
|
{
|
||||||
pdiff = diff_image->Buffer( lo_x, y );
|
pdiff = diff_image->Buffer( lo_x, y );
|
||||||
|
@ -225,21 +226,21 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
||||||
if ( *pdiff == WHITE )
|
if ( *pdiff == WHITE )
|
||||||
{
|
{
|
||||||
//printf( "Got white pixel at %d,%d (%x)\n", x, y, pdiff );
|
//printf( "Got white pixel at %d,%d (%x)\n", x, y, pdiff );
|
||||||
lx = x>lo_x?*(pdiff-1):0;
|
last_x = x>lo_x?*(pdiff-1):0;
|
||||||
ly = y>lo_y?*(pdiff-diff_image->Width()):0;
|
last_y = y>lo_y?*(pdiff-diff_width):0;
|
||||||
if ( lx )
|
if ( last_x )
|
||||||
{
|
{
|
||||||
//printf( "Left neighbour is %d\n", lx );
|
//printf( "Left neighbour is %d\n", last_x );
|
||||||
bsx = &blob_stats[lx];
|
bsx = &blob_stats[last_x];
|
||||||
if ( ly )
|
if ( last_y )
|
||||||
{
|
{
|
||||||
//printf( "Top neighbour is %d\n", ly );
|
//printf( "Top neighbour is %d\n", last_y );
|
||||||
bsy = &blob_stats[ly];
|
bsy = &blob_stats[last_y];
|
||||||
if ( lx == ly )
|
if ( last_x == last_y )
|
||||||
{
|
{
|
||||||
//printf( "Matching neighbours, setting to %d\n", lx );
|
//printf( "Matching neighbours, setting to %d\n", last_x );
|
||||||
// Add to the blob from the x side (either side really)
|
// Add to the blob from the x side (either side really)
|
||||||
*pdiff = lx;
|
*pdiff = last_x;
|
||||||
bsx->count++;
|
bsx->count++;
|
||||||
if ( x > bsx->hi_x ) bsx->hi_x = x;
|
if ( x > bsx->hi_x ) bsx->hi_x = x;
|
||||||
if ( y > bsx->hi_y ) bsx->hi_y = y;
|
if ( y > bsx->hi_y ) bsx->hi_y = y;
|
||||||
|
@ -292,9 +293,9 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf( "Setting to left neighbour %d\n", lx );
|
//printf( "Setting to left neighbour %d\n", last_x );
|
||||||
// Add to the blob from the x side
|
// Add to the blob from the x side
|
||||||
*pdiff = lx;
|
*pdiff = last_x;
|
||||||
bsx->count++;
|
bsx->count++;
|
||||||
if ( x > bsx->hi_x ) bsx->hi_x = x;
|
if ( x > bsx->hi_x ) bsx->hi_x = x;
|
||||||
if ( y > bsx->hi_y ) bsx->hi_y = y;
|
if ( y > bsx->hi_y ) bsx->hi_y = y;
|
||||||
|
@ -302,14 +303,14 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ly )
|
if ( last_y )
|
||||||
{
|
{
|
||||||
//printf( "Setting to top neighbour %d\n", ly );
|
//printf( "Setting to top neighbour %d\n", last_y );
|
||||||
|
|
||||||
// Add to the blob from the y side
|
// Add to the blob from the y side
|
||||||
BlobStats *bsy = &blob_stats[ly];
|
BlobStats *bsy = &blob_stats[last_y];
|
||||||
|
|
||||||
*pdiff = ly;
|
*pdiff = last_y;
|
||||||
bsy->count++;
|
bsy->count++;
|
||||||
if ( x > bsy->hi_x ) bsy->hi_x = x;
|
if ( x > bsy->hi_x ) bsy->hi_x = x;
|
||||||
if ( y > bsy->hi_y ) bsy->hi_y = y;
|
if ( y > bsy->hi_y ) bsy->hi_y = y;
|
||||||
|
@ -317,8 +318,8 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create a new blob
|
// Create a new blob
|
||||||
//for ( int i = 1; i < WHITE; i++ )
|
int i;
|
||||||
for ( int i = (WHITE-1); i > 0; i-- )
|
for ( i = (WHITE-1); i > 0; i-- )
|
||||||
{
|
{
|
||||||
BlobStats *bs = &blob_stats[i];
|
BlobStats *bs = &blob_stats[i];
|
||||||
if ( !bs->count )
|
if ( !bs->count )
|
||||||
|
@ -335,6 +336,15 @@ bool Zone::CheckAlarms( const Image *delta_image )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( i == 0 )
|
||||||
|
{
|
||||||
|
i = 1;
|
||||||
|
Warning(( "Max blob count reached. Unable to allocate new blob so extending last one." ));
|
||||||
|
BlobStats *bs = &blob_stats[i];
|
||||||
|
*pdiff = i;
|
||||||
|
if ( x > bs->hi_x ) bs->hi_x = x;
|
||||||
|
if ( y > bs->hi_y ) bs->hi_y = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue