Corrected warnings.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@450 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2003-04-07 10:56:38 +00:00
parent 18a52515d2
commit 94390d39e3
9 changed files with 27 additions and 36 deletions

View File

@ -67,7 +67,7 @@ Event::~Event()
strftime( end_time_str, sizeof(end_time_str), "%Y-%m-%d %H:%M:%S", localtime( &end_time.tv_sec ) );
sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %s%d.%02d, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, delta_time.positive?"":"-", delta_time.tv_sec, delta_time.tv_usec/10000, frames, alarm_frames, tot_score, (int)(tot_score/alarm_frames), max_score, id );
sprintf( sql, "update Events set Name='Event-%d', EndTime = '%s', Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", id, end_time_str, delta_time.positive?"":"-", delta_time.tv_sec, delta_time.tv_usec/10000, frames, alarm_frames, tot_score, (int)(tot_score/alarm_frames), max_score, id );
if ( mysql_query( &dbconn, sql ) )
{
Error(( "Can't update event: %s\n", mysql_error( &dbconn ) ));
@ -87,7 +87,7 @@ void Event::AddFrame( struct timeval timestamp, const Image *image, const Image
DELTA_TIMEVAL( delta_time, timestamp, start_time );
static char sql[256];
sprintf( sql, "insert into Frames set EventId=%d, FrameId=%d, AlarmFrame=%d, ImagePath='%s', Delta=%s%d.%02d, Score=%d", id, frames, alarm_image!=0, event_file, delta_time.positive?"":"-", delta_time.tv_sec, delta_time.tv_usec/10000, score );
sprintf( sql, "insert into Frames set EventId=%d, FrameId=%d, AlarmFrame=%d, ImagePath='%s', Delta=%s%ld.%02ld, Score=%d", id, frames, alarm_image!=0, event_file, delta_time.positive?"":"-", delta_time.tv_sec, delta_time.tv_usec/10000, score );
if ( mysql_query( &dbconn, sql ) )
{
Error(( "Can't insert frame: %s\n", mysql_error( &dbconn ) ));
@ -144,10 +144,10 @@ void Event::StreamEvent( const char *path, int event_id, unsigned long refresh,
{
char filepath[PATH_MAX];
sprintf( filepath, "%s/%s", path, dbrow[2] );
if ( fdj = fopen( filepath, "r" ) )
if ( (fdj = fopen( filepath, "r" )) )
{
fprintf( fd, "Content-type: image/jpg\r\n\r\n" );
while ( n_bytes = fread( buffer, 1, sizeof(buffer), fdj ) )
while ( (n_bytes = fread( buffer, 1, sizeof(buffer), fdj )) )
{
fwrite( buffer, 1, n_bytes, fd );
}

View File

@ -17,6 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "zm_font.h"
#include "zm_image.h"
Image *Image::HighlightEdges( Rgb colour, const Box *limits )
@ -384,7 +385,8 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con
assert( width == images[i]->width && height == images[i]->height && colours == images[i]->colours );
}
const Image *reference = Merge( n_images, images );
// Not even sure why this is here!!
//const Image *reference = Merge( n_images, images );
Image *result = new Image( width, height, images[0]->colours );
int size = result->size;
@ -398,7 +400,7 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con
{
JSAMPLE *psrc = images[j]->buffer+c;
if ( abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
if ( (unsigned)abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
{
count++;
}
@ -418,9 +420,6 @@ Image *Image::Delta( const Image &image, bool absolute ) const
Image *result = new Image( width, height, 1 );
typedef JSAMPLE IMAGE[width][height][colours];
IMAGE &data = reinterpret_cast<IMAGE &>(*buffer);
IMAGE &image_data = reinterpret_cast<IMAGE &>(*image.buffer);
IMAGE &diff_data = reinterpret_cast<IMAGE &>(*result->buffer);
unsigned char *psrc = buffer;
unsigned char *pref = image.buffer;
@ -621,7 +620,6 @@ void Image::Hatch( Rgb colour, const Box *limits )
int lo_y = limits?limits->Lo().Y():0;
int hi_x = limits?limits->Hi().X():width-1;
int hi_y = limits?limits->Hi().Y():height-1;
unsigned char *p = buffer;
for ( int y = lo_y; y <= hi_y; y++ )
{
unsigned char *p = &buffer[colours*((y*width)+lo_x)];

View File

@ -40,7 +40,6 @@ void jpeg_mem_src(j_decompress_ptr cinfo, JOCTET *inbuffer, int inbuffer_size );
void jpeg_mem_dest(j_compress_ptr cinfo, JOCTET *outbuffer, int *outbuffer_size );
}
#include "zm_font.h"
#include "zm_rgb.h"
#include "zm_coord.h"
#include "zm_box.h"

View File

@ -387,7 +387,7 @@ bool LocalCamera::GetCurrentSettings( int device, char *output, bool verbose )
}
else
{
sprintf( output+strlen(output), "n%d:%d,", chan, vid_src.name );
sprintf( output+strlen(output), "n%d:%s,", chan, vid_src.name );
sprintf( output+strlen(output), "C%d:%d,", chan, vid_src.channel );
sprintf( output+strlen(output), "Fl%d:%x,", chan, vid_src.flags );
sprintf( output+strlen(output), "T%d:%d", chan, vid_src.type );

View File

@ -170,7 +170,7 @@ public:
int index = image_count%image_buffer_count;
if ( index == shared_images->last_read_index )
if ( index == shared_images->last_read_index && function == ACTIVE )
{
Warning(( "Buffer overrun at index %d\n", index ));
}

View File

@ -235,7 +235,7 @@ int RemoteCamera::GetResponse( unsigned char *&buffer, int &max_size )
char version[4];
int code;
char message[64] = "";
int result = sscanf( header, "HTTP/%s %3d %[^\r\n]", &version, &code, &message );
int result = sscanf( header, "HTTP/%s %3d %[^\r\n]", version, &code, message );
if ( result != 3 )
{
@ -316,13 +316,11 @@ int RemoteCamera::PreCapture()
Disconnect();
return( -1 );
}
return( 0 );
}
unsigned char *RemoteCamera::PostCapture()
{
fd_set rfds;
int total_bytes = 0;
int max_size = width*height*colours;
unsigned char *buffer = (unsigned char *)malloc( max_size );
int content_length = GetResponse( buffer, max_size );
@ -337,9 +335,6 @@ unsigned char *RemoteCamera::PostCapture()
int RemoteCamera::PostCapture( Image &image )
{
fd_set rfds;
int total_bytes = 0;
int max_size = width*height*colours;
unsigned char *buffer = (unsigned char *)malloc( max_size );
int content_length = GetResponse( buffer, max_size );

View File

@ -75,7 +75,6 @@ void Zone::RecordStats( const Event *event )
bool Zone::CheckAlarms( const Image *delta_image )
{
bool alarm = false;
unsigned int score = 0;
ResetStats();
@ -381,13 +380,13 @@ bool Zone::CheckAlarms( const Image *delta_image )
{
score *= 2;
}
score = score;
// Now outline the changed region
if ( alarm_blobs )
{
alarm = true;
Image *high_image = image = diff_image->HighlightEdges( alarm_rgb, &limits );
//Image *high_image = image = diff_image->HighlightEdges( alarm_rgb, &limits );
image = diff_image->HighlightEdges( alarm_rgb, &limits );
delete diff_image;
//high_image->WriteJpeg( "diff4.jpg" );

View File

@ -60,9 +60,7 @@ int main( int argc, char *argv[] )
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
int opterr = 1;
int c = getopt_long (argc, argv, "d:H:P:p:h", long_options, &option_index);
if (c == -1)
@ -180,6 +178,7 @@ int main( int argc, char *argv[] )
}
struct timeval now;
struct DeltaTimeval delta_time;
while( !zmc_terminate )
{
/* grab a new one */
@ -198,11 +197,7 @@ int main( int argc, char *argv[] )
{
if ( last_capture_times[j].tv_sec )
{
static struct DeltaTimeval delta_time;
//Info(( "Now %d.%d", now.tv_sec, now.tv_usec ));
//Info(( "Capture %d.%d", last_capture_times[j].tv_sec, last_capture_times[j].tv_usec ));
DELTA_TIMEVAL( delta_time, now, last_capture_times[j] );
//Info(( "Delta %d-%d.%d", delta_time.positive, delta_time.tv_sec, delta_time.tv_usec ));
next_delays[j] = capture_delays[j]-((delta_time.tv_sec*1000000)+delta_time.tv_usec);
if ( next_delays[j] < 0 )
{
@ -213,7 +208,6 @@ int main( int argc, char *argv[] )
{
next_delays[j] = 0;
}
//Info(( "%d: %d", j, next_delays[j] ));
if ( next_delays[j] <= min_delay )
{
min_delay = next_delays[j];
@ -222,12 +216,20 @@ int main( int argc, char *argv[] )
}
if ( next_delays[i] <= min_delay || next_delays[i] <= 0 )
{
gettimeofday( &(last_capture_times[i]), &dummy_tz );
monitors[i]->PreCapture();
if ( next_delays[i] > 0 )
usleep( next_delays[i] );
monitors[i]->PostCapture();
if ( next_delays[i] > 0 )
{
gettimeofday( &now, &dummy_tz );
DELTA_TIMEVAL( delta_time, now, last_capture_times[i] );
long sleep_time = next_delays[i]-((delta_time.tv_sec*1000000)+delta_time.tv_usec);
if ( sleep_time > 0 )
{
usleep( sleep_time );
}
}
gettimeofday( &(last_capture_times[i]), &dummy_tz );
}
}
sigprocmask( SIG_UNBLOCK, &block_set, 0 );

View File

@ -120,8 +120,6 @@ int main( int argc, char *argv[] )
exit( mysql_errno( &dbconn ) );
}
int n_devices = mysql_num_rows( result );
int *devices = new int [n_devices];
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
{
int device = atoi(dbrow[0]);