Added orientation and tidied up a bit.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@529 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
726e5049b6
commit
b5d6859bd4
|
@ -1,3 +1,3 @@
|
|||
AUTOMAKE_OPTIONS = gnu
|
||||
|
||||
EXTRA_DIST = zmschema.sql.z zmalter-0.0.1.sql zmalter-0.9.7.sql zmalter-0.9.8.sql zmalter-0.9.9.sql zmalter-0.9.10.sql
|
||||
EXTRA_DIST = zmschema.sql.z zmalter-0.0.1.sql zmalter-0.9.7.sql zmalter-0.9.8.sql zmalter-0.9.9.sql zmalter-0.9.10.sql zmalter-0.9.11.sql
|
||||
|
|
|
@ -117,7 +117,7 @@ sysconfdir = @sysconfdir@
|
|||
target_alias = @target_alias@
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
|
||||
EXTRA_DIST = zmschema.sql.z zmalter-0.0.1.sql zmalter-0.9.7.sql zmalter-0.9.8.sql zmalter-0.9.9.sql zmalter-0.9.10.sql
|
||||
EXTRA_DIST = zmschema.sql.z zmalter-0.0.1.sql zmalter-0.9.7.sql zmalter-0.9.8.sql zmalter-0.9.9.sql zmalter-0.9.10.sql zmalter-0.9.11.sql
|
||||
subdir = db
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
--
|
||||
-- This updates a 0.9.11 database to 0.9.12
|
||||
--
|
||||
alter table Monitors add column Orientation enum('0','90','180','270') not null default '0' after Palette;
|
||||
-- These are optional, it just seemed a good time...
|
||||
optimize table Frames;
|
||||
optimize table Events;
|
||||
optimize table Filters;
|
||||
optimize table Zones;
|
||||
optimize table Monitors;
|
||||
optimize table Stats;
|
|
@ -94,6 +94,7 @@ CREATE TABLE Monitors (
|
|||
Width smallint(5) unsigned NOT NULL default '0',
|
||||
Height smallint(5) unsigned NOT NULL default '0',
|
||||
Palette tinyint(3) unsigned NOT NULL default '1',
|
||||
Orientation enum('0','90','180','270') NOT NULL default '0',
|
||||
LabelFormat varchar(32) NOT NULL default '%%s - %y/%m/%d %H:%M:%S',
|
||||
LabelX smallint(5) unsigned default NULL,
|
||||
LabelY smallint(5) unsigned default NULL,
|
||||
|
|
|
@ -56,19 +56,7 @@ public:
|
|||
unsigned int ImageSize() const { return( colours*width*height ); }
|
||||
|
||||
virtual int PreCapture()=0;
|
||||
virtual unsigned char *PostCapture()=0;
|
||||
virtual int PostCapture( Image &image )=0;
|
||||
|
||||
inline unsigned char *Capture()
|
||||
{
|
||||
PreCapture();
|
||||
return( PostCapture() );
|
||||
}
|
||||
inline int Capture( Image &image )
|
||||
{
|
||||
PreCapture();
|
||||
return( PostCapture( image ) );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ZM_CAMERA_H
|
||||
|
|
|
@ -53,3 +53,8 @@
|
|||
#define ZM_OPT_ADAPTIVE_SKIP <from zmconfig> // Whether we use the adaptive skip algorithm
|
||||
#define ZM_OPT_FRAME_SERVER <from zmconfig> // Whether we use the frame server to speed things up
|
||||
|
||||
#define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling
|
||||
#define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling
|
||||
#define ZM_MAX_IMAGE_COLOURS 3 // The largest image we imagine ever handling
|
||||
#define ZM_MAX_IMAGE_DIM (ZM_MAX_IMAGE_WIDTH*ZM_MAX_IMAGE_HEIGHT)
|
||||
#define ZM_MAX_IMAGE_SIZE (ZM_MAX_IMAGE_DIM*ZM_MAX_IMAGE_COLOURS)
|
||||
|
|
|
@ -150,7 +150,7 @@ bool Event::SendFrameImage( const Image *image, bool alarm_frame )
|
|||
|
||||
static int jpg_buffer_size = 0;
|
||||
//static unsigned char jpg_buffer[monitor->CameraWidth()*monitor->CameraHeight()];
|
||||
static unsigned char jpg_buffer[2048*1536];
|
||||
static unsigned char jpg_buffer[ZM_MAX_IMAGE_SIZE];
|
||||
|
||||
image->EncodeJpeg( jpg_buffer, &jpg_buffer_size );
|
||||
|
||||
|
|
120
src/zm_image.cpp
120
src/zm_image.cpp
|
@ -706,3 +706,123 @@ void Image::Fill( Rgb colour, const Box *limits )
|
|||
}
|
||||
}
|
||||
|
||||
void Image::Rotate( int angle )
|
||||
{
|
||||
angle %= 360;
|
||||
|
||||
if ( !angle )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( angle%90 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
static unsigned char rotate_buffer[ZM_MAX_IMAGE_SIZE];
|
||||
switch( angle )
|
||||
{
|
||||
case 90 :
|
||||
{
|
||||
int temp = width;
|
||||
width = height;
|
||||
height = temp;
|
||||
|
||||
unsigned char *s_ptr = buffer;
|
||||
|
||||
if ( colours == 1 )
|
||||
{
|
||||
unsigned char *d_ptr;
|
||||
for ( int i = width-1; i >= 0; i-- )
|
||||
{
|
||||
d_ptr = rotate_buffer+i;
|
||||
for ( int j = height-1; j >= 0; j-- )
|
||||
{
|
||||
*d_ptr = *s_ptr++;
|
||||
d_ptr += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *d_ptr;
|
||||
for ( int i = width-1; i >= 0; i-- )
|
||||
{
|
||||
d_ptr = rotate_buffer+(3*i);
|
||||
for ( int j = height-1; j >= 0; j-- )
|
||||
{
|
||||
*d_ptr = *s_ptr++;
|
||||
*(d_ptr+1) = *s_ptr++;
|
||||
*(d_ptr+2) = *s_ptr++;
|
||||
d_ptr += (3*width);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 180 :
|
||||
{
|
||||
unsigned char *s_ptr = buffer+size;
|
||||
unsigned char *d_ptr = rotate_buffer;
|
||||
|
||||
if ( colours == 1 )
|
||||
{
|
||||
while( s_ptr > buffer )
|
||||
{
|
||||
s_ptr--;
|
||||
*d_ptr++ = *s_ptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( s_ptr > buffer )
|
||||
{
|
||||
s_ptr -= 3;
|
||||
*d_ptr++ = *s_ptr;
|
||||
*d_ptr++ = *(s_ptr+1);
|
||||
*d_ptr++ = *(s_ptr+2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 270 :
|
||||
{
|
||||
int temp = width;
|
||||
width = height;
|
||||
height = temp;
|
||||
|
||||
unsigned char *s_ptr = buffer+size;
|
||||
|
||||
if ( colours == 1 )
|
||||
{
|
||||
unsigned char *d_ptr;
|
||||
for ( int i = width-1; i >= 0; i-- )
|
||||
{
|
||||
d_ptr = rotate_buffer+i;
|
||||
for ( int j = height-1; j >= 0; j-- )
|
||||
{
|
||||
s_ptr--;
|
||||
*d_ptr = *s_ptr;
|
||||
d_ptr += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *d_ptr;
|
||||
for ( int i = width-1; i >= 0; i-- )
|
||||
{
|
||||
d_ptr = rotate_buffer+(3*i);
|
||||
for ( int j = height-1; j >= 0; j-- )
|
||||
{
|
||||
*(d_ptr+2) = *(--s_ptr);
|
||||
*(d_ptr+1) = *(--s_ptr);
|
||||
*d_ptr = *(--s_ptr);
|
||||
d_ptr += (3*width);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
memcpy( buffer, rotate_buffer, size );
|
||||
}
|
||||
|
|
|
@ -121,10 +121,14 @@ public:
|
|||
width = p_width;
|
||||
height = p_height;
|
||||
colours = p_colours;
|
||||
size = width*height*colours;
|
||||
delete[] buffer;
|
||||
buffer = new JSAMPLE[size];
|
||||
memset( buffer, 0, size );
|
||||
int new_size = width*height*colours;
|
||||
if ( size != new_size )
|
||||
{
|
||||
size = new_size;
|
||||
delete[] buffer;
|
||||
buffer = new JSAMPLE[size];
|
||||
memset( buffer, 0, size );
|
||||
}
|
||||
}
|
||||
memcpy( buffer, new_buffer, size );
|
||||
}
|
||||
|
@ -164,6 +168,7 @@ public:
|
|||
void Fill( Rgb colour, const Box *limits=0 );
|
||||
void Hatch( Rgb colour, const Box *limits=0 );
|
||||
|
||||
void Rotate( int angle );
|
||||
};
|
||||
|
||||
#endif // ZM_IMAGE_H
|
||||
|
|
|
@ -446,22 +446,6 @@ int LocalCamera::PreCapture()
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
unsigned char *LocalCamera::PostCapture()
|
||||
{
|
||||
//Info(( "%s: Capturing image", id ));
|
||||
|
||||
if ( ioctl(m_videohandle, VIDIOCSYNC, &m_sync_frame) )
|
||||
{
|
||||
Error(( "Sync failure for frame %d: %s", m_sync_frame, strerror(errno)));
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
unsigned char *buffer = m_buffer+(m_sync_frame*m_vmb.size/m_vmb.frames);
|
||||
m_sync_frame = (m_sync_frame+1)%m_vmb.frames;
|
||||
|
||||
return( buffer );
|
||||
}
|
||||
|
||||
int LocalCamera::PostCapture( Image &image )
|
||||
{
|
||||
//Info(( "%s: Capturing image", id ));
|
||||
|
@ -475,14 +459,14 @@ int LocalCamera::PostCapture( Image &image )
|
|||
unsigned char *buffer = m_buffer+(m_sync_frame*m_vmb.size/m_vmb.frames);
|
||||
m_sync_frame = (m_sync_frame+1)%m_vmb.frames;
|
||||
|
||||
static unsigned char temp_buffer[2048*1536];
|
||||
static unsigned char temp_buffer[ZM_MAX_IMAGE_SIZE];
|
||||
switch( palette )
|
||||
{
|
||||
case VIDEO_PALETTE_YUV420P :
|
||||
{
|
||||
static unsigned char y_plane[2048*1536];
|
||||
static char u_plane[2048*1536];
|
||||
static char v_plane[2048*1536];
|
||||
static unsigned char y_plane[ZM_MAX_IMAGE_DIM];
|
||||
static char u_plane[ZM_MAX_IMAGE_DIM];
|
||||
static char v_plane[ZM_MAX_IMAGE_DIM];
|
||||
|
||||
unsigned char *rgb_ptr = temp_buffer;
|
||||
unsigned char *y_ptr = y_plane;
|
||||
|
@ -632,6 +616,7 @@ int LocalCamera::PostCapture( Image &image )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
image.Assign( width, height, colours, buffer );
|
||||
|
||||
return( 0 );
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
unsigned int Format() const { return( format ); }
|
||||
|
||||
int PreCapture();
|
||||
unsigned char *PostCapture();
|
||||
int PostCapture( Image &image );
|
||||
|
||||
static bool GetCurrentSettings( int device, char *output, bool verbose );
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
#include "zm_local_camera.h"
|
||||
#include "zm_remote_camera.h"
|
||||
|
||||
Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_colours, bool p_capture, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( p_width, p_height, p_colours ), ref_image( p_width, p_height, p_colours ), n_zones( p_n_zones ), zones( p_zones )
|
||||
Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_capture, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), n_zones( p_n_zones ), zones( p_zones )
|
||||
{
|
||||
name = new char[strlen(p_name)+1];
|
||||
strcpy( name, p_name );
|
||||
|
||||
strcpy( label_format, p_label_format );
|
||||
|
||||
camera = new LocalCamera( p_device, p_channel, p_format, p_width, p_height, p_colours, p_capture );
|
||||
camera = new LocalCamera( p_device, p_channel, p_format, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, p_capture );
|
||||
|
||||
fps = 0.0;
|
||||
event_count = 0;
|
||||
|
@ -74,13 +74,13 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_ch
|
|||
for ( int i = 0; i < image_buffer_count; i++ )
|
||||
{
|
||||
image_buffer[i].timestamp = &(shared_images->timestamps[i]);
|
||||
image_buffer[i].image = new Image( camera->Width(), camera->Height(), camera->Colours(), &(shared_images->images[i*camera->ImageSize()]) );
|
||||
image_buffer[i].image = new Image( width, height, camera->Colours(), &(shared_images->images[i*camera->ImageSize()]) );
|
||||
}
|
||||
if ( !n_zones )
|
||||
{
|
||||
n_zones = 1;
|
||||
zones = new Zone *[1];
|
||||
zones[0] = new Zone( this, 0, "All", Zone::ACTIVE, Box( camera->Width(), camera->Height() ), RGB_RED );
|
||||
zones[0] = new Zone( this, 0, "All", Zone::ACTIVE, Box( width, height ), RGB_RED );
|
||||
}
|
||||
start_time = last_fps_time = time( 0 );
|
||||
|
||||
|
@ -92,7 +92,7 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_ch
|
|||
|
||||
if ( !p_capture )
|
||||
{
|
||||
ref_image.Assign( camera->Width(), camera->Height(), camera->Colours(), image_buffer[shared_images->last_write_index].image->Buffer() );
|
||||
ref_image.Assign( width, height, camera->Colours(), image_buffer[shared_images->last_write_index].image->Buffer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -127,14 +127,14 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, int p_device, int p_ch
|
|||
record_event_stats = ZM_RECORD_EVENT_STATS;
|
||||
}
|
||||
|
||||
Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_colours, bool p_capture, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( p_width, p_height, p_colours ), ref_image( p_width, p_height, p_colours ), n_zones( p_n_zones ), zones( p_zones )
|
||||
Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_capture, int p_n_zones, Zone *p_zones[] ) : id( p_id ), function( (Function)p_function ), width( p_width ), height( p_height ), orientation( (Orientation)p_orientation ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), pre_event_count( p_pre_event_count ), post_event_count( p_post_event_count ), capture_delay( p_capture_delay ), fps_report_interval( p_fps_report_interval ), ref_blend_perc( p_ref_blend_perc ), image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), ref_image( width, height, (p_palette==VIDEO_PALETTE_GREY?1:3) ), n_zones( p_n_zones ), zones( p_zones )
|
||||
{
|
||||
name = new char[strlen(p_name)+1];
|
||||
strcpy( name, p_name );
|
||||
|
||||
strcpy( label_format, p_label_format );
|
||||
|
||||
camera = new RemoteCamera( p_host, p_port, p_path, p_width, p_height, p_colours, p_capture );
|
||||
camera = new RemoteCamera( p_host, p_port, p_path, (p_orientation%2)?width:height, (orientation%2)?height:width, p_palette, p_capture );
|
||||
|
||||
fps = 0.0;
|
||||
event_count = 0;
|
||||
|
@ -174,13 +174,13 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, co
|
|||
for ( int i = 0; i < image_buffer_count; i++ )
|
||||
{
|
||||
image_buffer[i].timestamp = &(shared_images->timestamps[i]);
|
||||
image_buffer[i].image = new Image( camera->Width(), camera->Height(), camera->Colours(), &(shared_images->images[i*camera->ImageSize()]) );
|
||||
image_buffer[i].image = new Image( width, height, camera->Colours(), &(shared_images->images[i*camera->ImageSize()]) );
|
||||
}
|
||||
if ( !n_zones )
|
||||
{
|
||||
n_zones = 1;
|
||||
zones = new Zone *[1];
|
||||
zones[0] = new Zone( this, 0, "All", Zone::ACTIVE, Box( camera->Width(), camera->Height() ), RGB_RED );
|
||||
zones[0] = new Zone( this, 0, "All", Zone::ACTIVE, Box( width, height ), RGB_RED );
|
||||
}
|
||||
start_time = last_fps_time = time( 0 );
|
||||
|
||||
|
@ -192,7 +192,7 @@ Monitor::Monitor( int p_id, char *p_name, int p_function, const char *p_host, co
|
|||
|
||||
if ( !p_capture )
|
||||
{
|
||||
ref_image.Assign( camera->Width(), camera->Height(), camera->Colours(), image_buffer[shared_images->last_write_index].image->Buffer() );
|
||||
ref_image.Assign( width, height, camera->Colours(), image_buffer[shared_images->last_write_index].image->Buffer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -558,11 +558,11 @@ int Monitor::Load( int device, Monitor **&monitors, bool capture )
|
|||
static char sql[256];
|
||||
if ( device == -1 )
|
||||
{
|
||||
strcpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None'" );
|
||||
strcpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None'" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Device = %d", device );
|
||||
sprintf( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Device = %d", device );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -582,7 +582,7 @@ int Monitor::Load( int device, Monitor **&monitors, bool capture )
|
|||
monitors = new Monitor *[n_monitors];
|
||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
||||
{
|
||||
monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), capture, dbrow[9], Coord( atoi(dbrow[10]), atoi(dbrow[11]) ), atoi(dbrow[12]), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atof(dbrow[16])>0.0?int(1000.0/atof(dbrow[16])):0, atoi(dbrow[17]), atoi(dbrow[18]) );
|
||||
monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), atoi(dbrow[9]), dbrow[10], Coord( atoi(dbrow[11]), atoi(dbrow[12]) ), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atoi(dbrow[16]), atof(dbrow[17])>0.0?int(1000.0/atof(dbrow[17])):0, atoi(dbrow[18]), atoi(dbrow[19]), capture );
|
||||
Zone **zones = 0;
|
||||
int n_zones = Zone::Load( monitors[i], zones );
|
||||
monitors[i]->AddZones( n_zones, zones );
|
||||
|
@ -604,11 +604,11 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor
|
|||
static char sql[256];
|
||||
if ( !host )
|
||||
{
|
||||
strcpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None'" );
|
||||
strcpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None'" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Host = '%s' and Port = '%s' and Path = '%s'", host, port, path );
|
||||
sprintf( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Host = '%s' and Port = '%s' and Path = '%s'", host, port, path );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -628,7 +628,7 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor
|
|||
monitors = new Monitor *[n_monitors];
|
||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
||||
{
|
||||
monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), dbrow[3], dbrow[4], dbrow[5], atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), capture, dbrow[9], Coord( atoi(dbrow[10]), atoi(dbrow[11]) ), atoi(dbrow[12]), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atof(dbrow[16])>0.0?int(1000.0/atof(dbrow[16])):0, atoi(dbrow[17]), atoi(dbrow[18]) );
|
||||
monitors[i] = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[2]), dbrow[3], dbrow[4], dbrow[5], atoi(dbrow[6]), atoi(dbrow[7]), atoi(dbrow[8]), atoi(dbrow[9]), dbrow[10], Coord( atoi(dbrow[11]), atoi(dbrow[12]) ), atoi(dbrow[13]), atoi(dbrow[14]), atoi(dbrow[15]), atoi(dbrow[16]), atof(dbrow[17])>0.0?int(1000.0/atof(dbrow[17])):0, atoi(dbrow[18]), atoi(dbrow[19]), capture );
|
||||
Zone **zones = 0;
|
||||
int n_zones = Zone::Load( monitors[i], zones );
|
||||
monitors[i]->AddZones( n_zones, zones );
|
||||
|
@ -648,7 +648,7 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor
|
|||
Monitor *Monitor::Load( int id, bool load_zones )
|
||||
{
|
||||
static char sql[256];
|
||||
sprintf( sql, "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id );
|
||||
sprintf( sql, "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
|
@ -668,11 +668,11 @@ Monitor *Monitor::Load( int id, bool load_zones )
|
|||
{
|
||||
if ( !strcmp( dbrow[2], "Local" ) )
|
||||
{
|
||||
monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), false, dbrow[13], Coord( atoi(dbrow[14]), atoi(dbrow[15]) ), atoi(dbrow[16]), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atof(dbrow[20])>0.0?int(1000.0/atof(dbrow[20])):0, atoi(dbrow[21]), atoi(dbrow[22]) );
|
||||
monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), atoi(dbrow[4]), atoi(dbrow[5]), atoi(dbrow[6]), atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), atoi(dbrow[13]), dbrow[14], Coord( atoi(dbrow[15]), atoi(dbrow[16]) ), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atoi(dbrow[20]), atof(dbrow[21])>0.0?int(1000.0/atof(dbrow[21])):0, atoi(dbrow[22]), atoi(dbrow[23]), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), dbrow[7], dbrow[8], dbrow[9], atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), false, dbrow[13], Coord( atoi(dbrow[14]), atoi(dbrow[15]) ), atoi(dbrow[16]), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atof(dbrow[20])>0.0?int(1000.0/atof(dbrow[20])):0, atoi(dbrow[21]), atoi(dbrow[22]) );
|
||||
monitor = new Monitor( atoi(dbrow[0]), dbrow[1], atoi(dbrow[3]), dbrow[7], dbrow[8], dbrow[9], atoi(dbrow[10]), atoi(dbrow[11]), atoi(dbrow[12]), atoi(dbrow[13]), dbrow[14], Coord( atoi(dbrow[15]), atoi(dbrow[16]) ), atoi(dbrow[17]), atoi(dbrow[18]), atoi(dbrow[19]), atoi(dbrow[20]), atof(dbrow[21])>0.0?int(1000.0/atof(dbrow[21])):0, atoi(dbrow[22]), atoi(dbrow[23]), false );
|
||||
}
|
||||
int n_zones = 0;
|
||||
if ( load_zones )
|
||||
|
@ -765,7 +765,7 @@ bool Monitor::DumpSettings( char *output, bool verbose )
|
|||
sprintf( output+strlen(output), "Port : %s\n", ((RemoteCamera *)camera)->Port() );
|
||||
sprintf( output+strlen(output), "Path : %s\n", ((RemoteCamera *)camera)->Path() );
|
||||
}
|
||||
sprintf( output+strlen(output), "Width : %d\n", ((LocalCamera *)camera)->Width() );
|
||||
sprintf( output+strlen(output), "Width : %d\n", camera->Width() );
|
||||
sprintf( output+strlen(output), "Height : %d\n", camera->Height() );
|
||||
sprintf( output+strlen(output), "Palette : %d\n", camera->Palette() );
|
||||
sprintf( output+strlen(output), "Colours : %d\n", camera->Colours() );
|
||||
|
|
|
@ -44,13 +44,18 @@ public:
|
|||
X10
|
||||
} Function;
|
||||
|
||||
typedef enum { ROTATE_0=1, ROTATE_90, ROTATE_180, ROTATE_270 } Orientation;
|
||||
|
||||
typedef enum { IDLE, ALARM, ALERT } State;
|
||||
|
||||
protected:
|
||||
// These are read from the DB and thereafter remain unchanged
|
||||
int id;
|
||||
char *name;
|
||||
Function function;
|
||||
unsigned int width; // Normally the same as the camera, but not if partly rotated
|
||||
unsigned int height; // Normally the same as the camera, but not if partly rotated
|
||||
Function function; // What the monitor is doing
|
||||
Orientation orientation; // Whether the image has to be rotated at all
|
||||
char label_format[64]; // The format of the timestamp on the images
|
||||
Coord label_coord; // The coordinates of the timestamp on the images
|
||||
int image_buffer_count; // Size of circular image buffer, at least twice the size of the pre_event_count
|
||||
|
@ -105,8 +110,8 @@ protected:
|
|||
Camera *camera;
|
||||
|
||||
public:
|
||||
Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_colours, bool p_capture, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_colours, bool p_capture, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_capture, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_capture, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
~Monitor();
|
||||
|
||||
void AddZones( int p_n_zones, Zone *p_zones[] );
|
||||
|
@ -135,19 +140,8 @@ public:
|
|||
bool DumpSettings( char *output, bool verbose );
|
||||
void DumpZoneImage();
|
||||
|
||||
unsigned int CameraWidth() const { return( camera->Width() ); }
|
||||
unsigned int CameraHeight() const { return( camera->Height() ); }
|
||||
inline int Capture()
|
||||
{
|
||||
if ( camera->PreCapture() == 0 )
|
||||
{
|
||||
if ( camera->PostCapture() == 0 )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
return( -1 );
|
||||
}
|
||||
unsigned int Width() const { return( width ); }
|
||||
unsigned int Height() const { return( height ); }
|
||||
inline int PreCapture()
|
||||
{
|
||||
return( camera->PreCapture() );
|
||||
|
@ -156,6 +150,11 @@ public:
|
|||
{
|
||||
if ( camera->PostCapture( image ) == 0 )
|
||||
{
|
||||
if ( orientation != ROTATE_0 )
|
||||
{
|
||||
image.Rotate( (orientation-1)*90 );
|
||||
}
|
||||
|
||||
char label_time_text[64];
|
||||
char label_text[64];
|
||||
time_t now = time( 0 );
|
||||
|
@ -176,8 +175,6 @@ public:
|
|||
}
|
||||
gettimeofday( image_buffer[index].timestamp, &dummy_tz );
|
||||
image_buffer[index].image->CopyBuffer( image );
|
||||
//memcpy( image_buffer[index].image->buffer, image.buffer, image.size );
|
||||
//Info(( "%d: %x - %x", index, image_buffer[index].image, image_buffer[index].image->buffer ));
|
||||
|
||||
shared_images->last_write_index = index;
|
||||
|
||||
|
|
|
@ -319,20 +319,6 @@ int RemoteCamera::PreCapture()
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
unsigned char *RemoteCamera::PostCapture()
|
||||
{
|
||||
int max_size = width*height*colours;
|
||||
unsigned char *buffer = (unsigned char *)malloc( max_size );
|
||||
int content_length = GetResponse( buffer, max_size );
|
||||
if ( content_length < 0 )
|
||||
{
|
||||
Disconnect();
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
return( buffer );
|
||||
}
|
||||
|
||||
int RemoteCamera::PostCapture( Image &image )
|
||||
{
|
||||
int max_size = width*height*colours;
|
||||
|
|
|
@ -73,7 +73,6 @@ public:
|
|||
int GetHeader( const char *content, const char *header, char *value );
|
||||
int GetResponse( unsigned char *&buffer, int &max_size );
|
||||
int PreCapture();
|
||||
unsigned char *PostCapture();
|
||||
int PostCapture( Image &image );
|
||||
};
|
||||
|
||||
|
|
|
@ -437,16 +437,16 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
|||
|
||||
if ( !strcmp( Units, "Percent" ) )
|
||||
{
|
||||
LoX = (LoX*(monitor->CameraWidth()-1))/100;
|
||||
LoY = (LoY*(monitor->CameraHeight()-1))/100;
|
||||
HiX = (HiX*(monitor->CameraWidth()-1))/100;
|
||||
HiY = (HiY*(monitor->CameraHeight()-1))/100;
|
||||
MinAlarmPixels = (MinAlarmPixels*monitor->CameraWidth()*monitor->CameraHeight())/100;
|
||||
MaxAlarmPixels = (MaxAlarmPixels*monitor->CameraWidth()*monitor->CameraHeight())/100;
|
||||
MinFilterPixels = (MinFilterPixels*monitor->CameraWidth()*monitor->CameraHeight())/100;
|
||||
MaxFilterPixels = (MaxFilterPixels*monitor->CameraWidth()*monitor->CameraHeight())/100;
|
||||
MinBlobPixels = (MinBlobPixels*monitor->CameraWidth()*monitor->CameraHeight())/100;
|
||||
MaxBlobPixels = (MaxBlobPixels*monitor->CameraWidth()*monitor->CameraHeight())/100;
|
||||
LoX = (LoX*(monitor->Width()-1))/100;
|
||||
LoY = (LoY*(monitor->Height()-1))/100;
|
||||
HiX = (HiX*(monitor->Width()-1))/100;
|
||||
HiY = (HiY*(monitor->Height()-1))/100;
|
||||
MinAlarmPixels = (MinAlarmPixels*monitor->Width()*monitor->Height())/100;
|
||||
MaxAlarmPixels = (MaxAlarmPixels*monitor->Width()*monitor->Height())/100;
|
||||
MinFilterPixels = (MinFilterPixels*monitor->Width()*monitor->Height())/100;
|
||||
MaxFilterPixels = (MaxFilterPixels*monitor->Width()*monitor->Height())/100;
|
||||
MinBlobPixels = (MinBlobPixels*monitor->Width()*monitor->Height())/100;
|
||||
MaxBlobPixels = (MaxBlobPixels*monitor->Width()*monitor->Height())/100;
|
||||
}
|
||||
|
||||
if ( atoi(dbrow[2]) == Zone::INACTIVE )
|
||||
|
|
|
@ -247,6 +247,7 @@ if ( $action )
|
|||
if ( $new_width != $monitor['Width'] ) $changes[] = "Width = '$new_width'";
|
||||
if ( $new_height != $monitor['Height'] ) $changes[] = "Height = '$new_height'";
|
||||
if ( $new_colours != $monitor['Palette'] ) $changes[] = "Palette = '$new_palette'";
|
||||
if ( $new_orientation != $monitor['Orientation'] ) $changes[] = "Orientation = '$new_orientation'";
|
||||
if ( $new_label_format != $monitor['LabelFormat'] ) $changes[] = "LabelFormat = '$new_label_format'";
|
||||
if ( $new_label_x != $monitor['LabelX'] ) $changes[] = "LabelX = '$new_label_x'";
|
||||
if ( $new_label_y != $monitor['LabelY'] ) $changes[] = "LabelY = '$new_label_y'";
|
||||
|
|
|
@ -145,7 +145,7 @@ $jws = array(
|
|||
'console' => array( 'w'=>720, 'h'=>400 ),
|
||||
'cycle' => array( 'w'=>46, 'h'=>80 ),
|
||||
'montage' => array( 'w'=>20, 'h'=>20 ),
|
||||
'monitor' => array( 'w'=>420, 'h'=>492 ),
|
||||
'monitor' => array( 'w'=>420, 'h'=>512 ),
|
||||
'watch' => array( 'w'=>72, 'h'=>315 ),
|
||||
'device' => array( 'w'=>196, 'h'=>164 ),
|
||||
'function' => array( 'w'=>248, 'h'=>92 ),
|
||||
|
|
|
@ -1217,7 +1217,7 @@ location.href = '<?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?
|
|||
</table></td></tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr><td align="right"><?php if ( LEARN_MODE ) { ?><select name="learn_state" class="form" disabled><option value="">Ignore</option><option value="-">Exclude</option><option value="+">Include</option></select> <input type="button" name="learn_btn" value="Set Learn Prefs" class="form" onClick="event_form.action.value = 'learn'; event_form.submit();" disabled> <?php } ?><input type="button" name="delete_btn" value="Delete" class="form" onClick="event_form.action.value = 'delete'; event_form.submit();" disabled></td></tr>
|
||||
<tr><td align="right"><?php if ( LEARN_MODE ) { ?><select name="learn_state" class="form" disabled><option value="">Ignore</option><option value="-">Exclude</option><option value="+">Include</option></select> <input type="button" name="learn_btn" value="Set Learn Prefs" class="form" onClick="document.event_form.action.value = 'learn'; document.event_form.submit();" disabled> <?php } ?><input type="button" name="delete_btn" value="Delete" class="form" onClick="document.event_form.action.value = 'delete'; document.event_form.submit();" disabled></td></tr>
|
||||
</table></center>
|
||||
</form>
|
||||
</body>
|
||||
|
@ -2059,6 +2059,7 @@ function configureButton(form,name)
|
|||
$monitor['Function'] = "None";
|
||||
$monitor[Type] = "Local";
|
||||
$monitor[Port] = "80";
|
||||
$monitor[Orientation] = "0";
|
||||
$monitor[LabelFormat] = '%%s - %y/%m/%d %H:%M:%S';
|
||||
$monitor[LabelX] = 0;
|
||||
$monitor[LabelY] = 0;
|
||||
|
@ -2072,6 +2073,7 @@ function configureButton(form,name)
|
|||
}
|
||||
$local_palettes = array( "Grey"=>1, "RGB24"=>4, "RGB565"=>3, "YUV420P"=>15 );
|
||||
$remote_palettes = array( "8 bit greyscale"=>1, "24 bit colour"=>4 );
|
||||
$orientations = array( "Normal"=>0, "Rotate Right"=>90, "Inverted"=>180, "Rotate Left"=>270 );
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -2128,7 +2130,7 @@ $select_name = "new_type";
|
|||
$$select_name = $$select_name?$$select_name:$monitor[Type];
|
||||
$source_types = array( "Local"=>"Local", "Remote"=>"Remote" );
|
||||
?>
|
||||
<tr><td align="left" class="text">Source Type</td><td><?php buildSelect( $select_name, $source_types, "monitor_form.submit();" ); ?></td></tr>
|
||||
<tr><td align="left" class="text">Source Type</td><td><?php buildSelect( $select_name, $source_types, "document.monitor_form.submit();" ); ?></td></tr>
|
||||
<?php
|
||||
if ( $$select_name == "Local" )
|
||||
{
|
||||
|
@ -2151,6 +2153,7 @@ $source_types = array( "Local"=>"Local", "Remote"=>"Remote" );
|
|||
?>
|
||||
<tr><td align="left" class="text">Capture Width (pixels)</td><td align="left" class="text"><input type="text" name="new_width" value="<?= $monitor[Width] ?>" size="4" class="form"></td></tr>
|
||||
<tr><td align="left" class="text">Capture Height (pixels)</td><td align="left" class="text"><input type="text" name="new_height" value="<?= $monitor[Height] ?>" size="4" class="form"></td></tr>
|
||||
<tr><td align="left" class="text">Orientation</td><td align="left" class="text"><select name="new_orientation" class="form"><?php foreach ( $orientations as $name => $value ) { ?><option value="<?= $value ?>"<?php if ( $value == $monitor[Orientation] ) { ?> selected<?php } ?>><?= $name ?></option><?php } ?></select></td></tr>
|
||||
<tr><td align="left" class="text">Timestamp Label Format</td><td align="left" class="text"><input type="text" name="new_label_format" value="<?= $monitor[LabelFormat] ?>" size="20" class="form"></td></tr>
|
||||
<tr><td align="left" class="text">Timestamp Label X</td><td align="left" class="text"><input type="text" name="new_label_x" value="<?= $monitor[LabelX] ?>" size="4" class="form"></td></tr>
|
||||
<tr><td align="left" class="text">Timestamp Label Y</td><td align="left" class="text"><input type="text" name="new_label_y" value="<?= $monitor[LabelY] ?>" size="4" class="form"></td></tr>
|
||||
|
@ -2168,7 +2171,7 @@ $source_types = array( "Local"=>"Local", "Remote"=>"Remote" );
|
|||
<?php } ?>
|
||||
<tr><td colspan="2" align="left" class="text"> </td></tr>
|
||||
<tr>
|
||||
<td align="left"><input type="submit" value="Save" class="form" onClick="monitor_form.view.value='none'; monitor_form.action.value='monitor';"></td>
|
||||
<td align="left"><input type="submit" value="Save" class="form" onClick="document.monitor_form.view.value='none'; document.monitor_form.action.value='monitor';"></td>
|
||||
<td align="left"><input type="button" value="Cancel" class="form" onClick="closeWindow()"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue