whitespace/tabs updates

This commit is contained in:
Isaac Connor 2017-01-08 16:12:19 -05:00
parent d63df84c98
commit fcc507b93e
6 changed files with 5207 additions and 5207 deletions

View File

@ -48,22 +48,22 @@ class Monitor;
// //
class Event class Event
{ {
friend class EventStream; friend class EventStream;
protected: protected:
static bool initialised; static bool initialised;
static char capture_file_format[PATH_MAX]; static char capture_file_format[PATH_MAX];
static char analyse_file_format[PATH_MAX]; static char analyse_file_format[PATH_MAX];
static char general_file_format[PATH_MAX]; static char general_file_format[PATH_MAX];
protected: protected:
static int sd; static int sd;
public: public:
typedef std::set<std::string> StringSet; typedef std::set<std::string> StringSet;
typedef std::map<std::string,StringSet> StringSetMap; typedef std::map<std::string,StringSet> StringSetMap;
protected: protected:
typedef enum { NORMAL, BULK, ALARM } FrameType; typedef enum { NORMAL, BULK, ALARM } FrameType;
struct PreAlarmData struct PreAlarmData
@ -77,7 +77,7 @@ protected:
static int pre_alarm_count; static int pre_alarm_count;
static PreAlarmData pre_alarm_data[MAX_PRE_ALARM_FRAMES]; static PreAlarmData pre_alarm_data[MAX_PRE_ALARM_FRAMES];
protected: protected:
unsigned int id; unsigned int id;
Monitor *monitor; Monitor *monitor;
struct timeval start_time; struct timeval start_time;
@ -90,10 +90,10 @@ protected:
unsigned int max_score; unsigned int max_score;
char path[PATH_MAX]; char path[PATH_MAX];
protected: protected:
int last_db_frame; int last_db_frame;
protected: protected:
static void Initialise() static void Initialise()
{ {
if ( initialised ) if ( initialised )
@ -108,11 +108,11 @@ protected:
void createNotes( std::string &notes ); void createNotes( std::string &notes );
public: public:
static bool OpenFrameSocket( int ); static bool OpenFrameSocket( int );
static bool ValidateFrameSocket( int ); static bool ValidateFrameSocket( int );
public: public:
Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap ); Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap );
~Event(); ~Event();
@ -133,10 +133,10 @@ public:
void AddFrames( int n_frames, Image **images, struct timeval **timestamps ); void AddFrames( int n_frames, Image **images, struct timeval **timestamps );
void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL ); void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL );
private: private:
void AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps ); void AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps );
public: public:
static const char *getSubPath( struct tm *time ) static const char *getSubPath( struct tm *time )
{ {
static char subpath[PATH_MAX] = ""; static char subpath[PATH_MAX] = "";
@ -148,7 +148,7 @@ public:
return( Event::getSubPath( localtime( time ) ) ); return( Event::getSubPath( localtime( time ) ) );
} }
public: public:
static int PreAlarmCount() static int PreAlarmCount()
{ {
return( pre_alarm_count ); return( pre_alarm_count );
@ -189,9 +189,9 @@ public:
class EventStream : public StreamBase class EventStream : public StreamBase
{ {
public: public:
protected: protected:
struct FrameData { struct FrameData {
//unsigned long id; //unsigned long id;
time_t timestamp; time_t timestamp;
@ -212,22 +212,22 @@ protected:
FrameData *frames; FrameData *frames;
}; };
protected: protected:
static const int STREAM_PAUSE_WAIT = 250000; // Microseconds static const int STREAM_PAUSE_WAIT = 250000; // Microseconds
static const StreamMode DEFAULT_MODE = SINGLE; static const StreamMode DEFAULT_MODE = SINGLE;
protected: protected:
StreamMode mode; StreamMode mode;
bool forceEventChange; bool forceEventChange;
protected: protected:
int curr_frame_id; int curr_frame_id;
double curr_stream_time; double curr_stream_time;
EventData *event_data; EventData *event_data;
protected: protected:
bool loadEventData( int event_id ); bool loadEventData( int event_id );
bool loadInitialEventData( int init_event_id, int init_frame_id ); bool loadInitialEventData( int init_event_id, int init_frame_id );
bool loadInitialEventData( int monitor_id, time_t event_time ); bool loadInitialEventData( int monitor_id, time_t event_time );
@ -236,7 +236,7 @@ protected:
void processCommand( const CmdMsg *msg ); void processCommand( const CmdMsg *msg );
bool sendFrame( int delta_us ); bool sendFrame( int delta_us );
public: public:
EventStream() EventStream()
{ {
mode = DEFAULT_MODE; mode = DEFAULT_MODE;

View File

@ -291,7 +291,7 @@ Monitor::Monitor(
Purpose p_purpose, Purpose p_purpose,
int p_n_zones, int p_n_zones,
Zone *p_zones[] Zone *p_zones[]
) : id( p_id ), ) : id( p_id ),
function( (Function)p_function ), function( (Function)p_function ),
enabled( p_enabled ), enabled( p_enabled ),
width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ),
@ -1916,7 +1916,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
} else { } else {
v4l_captures_per_frame = config.captures_per_frame; v4l_captures_per_frame = config.captures_per_frame;
} }
Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
col++; col++;
const char *method = dbrow[col]; col++; const char *method = dbrow[col]; col++;
@ -2537,7 +2537,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
} else { } else {
v4l_captures_per_frame = config.captures_per_frame; v4l_captures_per_frame = config.captures_per_frame;
} }
Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
col++; col++;
std::string protocol = dbrow[col]; col++; std::string protocol = dbrow[col]; col++;
@ -3039,49 +3039,49 @@ bool Monitor::closeEvent()
*/ */
/* /*
bool Monitor::OurCheckAlarms( Zone *zone, const Image *pImage ) bool Monitor::OurCheckAlarms( Zone *zone, const Image *pImage )
{ {
Info("Entering OurCheckAlarms >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); Info("Entering OurCheckAlarms >>>>>>>>>>>>>>>>>>>>>>>>>>>>");
unsigned char black_thr = 23; unsigned char black_thr = 23;
int min_alarm_score = 10; int min_alarm_score = 10;
int max_alarm_score = 99; int max_alarm_score = 99;
//bool alarm = false; //bool alarm = false;
unsigned int score; unsigned int score;
Polygon zone_polygon = zone->GetPolygon(); Polygon zone_polygon = zone->GetPolygon();
Info("Got polygon of a zone. It has %d vertices.", zone_polygon.getNumCoords()); Info("Got polygon of a zone. It has %d vertices.", zone_polygon.getNumCoords());
zone->ResetStats(); zone->ResetStats();
Info("ResetStats done."); Info("ResetStats done.");
if ( !zone->CheckOverloadCount() ) if ( !zone->CheckOverloadCount() )
{ {
Info("CheckOverloadCount() return false, we'll return false."); Info("CheckOverloadCount() return false, we'll return false.");
return( false ); return( false );
} }
Image *pMaskImage = new Image(pImage->Width(), pImage->Height(), ZM_COLOUR_GRAY8, pImage->SubpixelOrder()); Image *pMaskImage = new Image(pImage->Width(), pImage->Height(), ZM_COLOUR_GRAY8, pImage->SubpixelOrder());
Info("Mask image created."); Info("Mask image created.");
pMaskImage->Fill(BLACK); pMaskImage->Fill(BLACK);
Info("Mask image filled with BLACK."); Info("Mask image filled with BLACK.");
if (pImage->Colours() == ZM_COLOUR_GRAY8) if (pImage->Colours() == ZM_COLOUR_GRAY8)
{ {
Info("Analysed image is not colored! Set score = 0."); Info("Analysed image is not colored! Set score = 0.");
score = 0; score = 0;
} }
else else
{ {
Info("Start processing image."); Info("Start processing image.");
//Process image //Process image
unsigned char *buffer = (unsigned char*)pImage->Buffer(); unsigned char *buffer = (unsigned char*)pImage->Buffer();
unsigned char *mask_buffer = (unsigned char*)pMaskImage->Buffer(); unsigned char *mask_buffer = (unsigned char*)pMaskImage->Buffer();
int black_pixels_count = 0; int black_pixels_count = 0;
Info("Loop for black pixels counting and mask filling."); Info("Loop for black pixels counting and mask filling.");
while (buffer < (pImage->Buffer() + pImage->Size())) while (buffer < (pImage->Buffer() + pImage->Size()))
{ {
if ( (RED(buffer) < black_thr) && (GREEN(buffer) < black_thr) && (BLUE(buffer) < black_thr) ) if ( (RED(buffer) < black_thr) && (GREEN(buffer) < black_thr) && (BLUE(buffer) < black_thr) )
{ {
*mask_buffer = WHITE; *mask_buffer = WHITE;
black_pixels_count++; black_pixels_count++;
} }
@ -3110,21 +3110,21 @@ bool Monitor::OurCheckAlarms( Zone *zone, const Image *pImage )
} }
} }
zone->SetScore(score); zone->SetScore(score);
Info("Score have been set in zone."); Info("Score have been set in zone.");
//Get mask //Get mask
Rgb alarm_colour = RGB_RED; Rgb alarm_colour = RGB_RED;
Image *tempImage = pMaskImage->HighlightEdges(alarm_colour, &zone_polygon.Extent() ); Image *tempImage = pMaskImage->HighlightEdges(alarm_colour, &zone_polygon.Extent() );
Info("After HighlightEdges"); Info("After HighlightEdges");
zone->SetAlarmImage(tempImage); zone->SetAlarmImage(tempImage);
Info("After SetAlarmImage"); Info("After SetAlarmImage");
delete pMaskImage; delete pMaskImage;
Info("After Delete pMaskImage"); Info("After Delete pMaskImage");
delete tempImage; delete tempImage;
Info("Leaving OurCheckAlarms >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); Info("Leaving OurCheckAlarms >>>>>>>>>>>>>>>>>>>>>>>>>>>>");
return true; return true;
} }
unsigned int Monitor::DetectBlack(const Image &comp_image, Event::StringSet &zoneSet ) unsigned int Monitor::DetectBlack(const Image &comp_image, Event::StringSet &zoneSet )
@ -3135,8 +3135,8 @@ unsigned int Monitor::DetectBlack(const Image &comp_image, Event::StringSet &zon
if ( n_zones <= 0 ) return( alarm ); if ( n_zones <= 0 ) return( alarm );
// Coord alarm_centre; // Coord alarm_centre;
// int top_score = -1; // int top_score = -1;
// Find all alarm pixels in active zones // Find all alarm pixels in active zones
Info("Number of zones to process %d", n_zones); Info("Number of zones to process %d", n_zones);
@ -3158,30 +3158,30 @@ unsigned int Monitor::DetectBlack(const Image &comp_image, Event::StringSet &zon
Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() );
Info( "Zone is alarmed, zone score = %d", zone->Score() ); Info( "Zone is alarmed, zone score = %d", zone->Score() );
zoneSet.insert( zone->Label() ); zoneSet.insert( zone->Label() );
// if ( config.opt_control && track_motion ) // if ( config.opt_control && track_motion )
// { // {
// if ( (int)zone->Score() > top_score ) // if ( (int)zone->Score() > top_score )
// { // {
// top_score = zone->Score(); // top_score = zone->Score();
// alarm_centre = zone->GetAlarmCentre(); // alarm_centre = zone->GetAlarmCentre();
// } // }
// } // }
} }
Info( "Finish checking active zone %s", zone->Label() ); Info( "Finish checking active zone %s", zone->Label() );
} }
// if ( top_score > 0 ) // if ( top_score > 0 )
// { // {
// shared_data->alarm_x = alarm_centre.X(); // shared_data->alarm_x = alarm_centre.X();
// shared_data->alarm_y = alarm_centre.Y(); // shared_data->alarm_y = alarm_centre.Y();
// //
// Info( "Got alarm centre at %d,%d, at count %d", shared_data->alarm_x, shared_data->alarm_y, image_count ); // Info( "Got alarm centre at %d,%d, at count %d", shared_data->alarm_x, shared_data->alarm_y, image_count );
// } // }
// else // else
// { // {
// shared_data->alarm_x = shared_data->alarm_y = -1; // shared_data->alarm_x = shared_data->alarm_y = -1;
// } // }
// This is a small and innocent hack to prevent scores of 0 being returned in alarm state // This is a small and innocent hack to prevent scores of 0 being returned in alarm state
Info("Leaving DetectBlack <<<<<<<<<<<<<<<<<<<<<<<<<<<"); Info("Leaving DetectBlack <<<<<<<<<<<<<<<<<<<<<<<<<<<");

View File

@ -32,11 +32,11 @@ class Monitor;
class StreamBase class StreamBase
{ {
public: public:
typedef enum { JPEG, RAW, ZIP, MPEG } StreamType; typedef enum { JPEG, RAW, ZIP, MPEG } StreamType;
typedef enum { SINGLE, STREAM, ALL, ALL_GAPLESS } StreamMode; typedef enum { SINGLE, STREAM, ALL, ALL_GAPLESS } StreamMode;
protected: protected:
static const int MAX_STREAM_DELAY = 5; // Seconds static const int MAX_STREAM_DELAY = 5; // Seconds
static const StreamType DEFAULT_TYPE = JPEG; static const StreamType DEFAULT_TYPE = JPEG;
@ -46,7 +46,7 @@ protected:
enum { DEFAULT_MAXFPS=10 }; enum { DEFAULT_MAXFPS=10 };
enum { DEFAULT_BITRATE=100000 }; enum { DEFAULT_BITRATE=100000 };
protected: protected:
typedef struct { typedef struct {
int msg_type; int msg_type;
char msg_data[16]; char msg_data[16];
@ -60,7 +60,7 @@ protected:
typedef enum { MSG_CMD=1, MSG_DATA_WATCH, MSG_DATA_EVENT } MsgType; typedef enum { MSG_CMD=1, MSG_DATA_WATCH, MSG_DATA_EVENT } MsgType;
typedef enum { CMD_NONE=0, CMD_PAUSE, CMD_PLAY, CMD_STOP, CMD_FASTFWD, CMD_SLOWFWD, CMD_SLOWREV, CMD_FASTREV, CMD_ZOOMIN, CMD_ZOOMOUT, CMD_PAN, CMD_SCALE, CMD_PREV, CMD_NEXT, CMD_SEEK, CMD_VARPLAY, CMD_GET_IMAGE, CMD_QUERY=99 } MsgCommand; typedef enum { CMD_NONE=0, CMD_PAUSE, CMD_PLAY, CMD_STOP, CMD_FASTFWD, CMD_SLOWFWD, CMD_SLOWREV, CMD_FASTREV, CMD_ZOOMIN, CMD_ZOOMOUT, CMD_PAN, CMD_SCALE, CMD_PREV, CMD_NEXT, CMD_SEEK, CMD_VARPLAY, CMD_GET_IMAGE, CMD_QUERY=99 } MsgCommand;
protected: protected:
Monitor *monitor; Monitor *monitor;
StreamType type; StreamType type;
@ -73,7 +73,7 @@ protected:
int bitrate; int bitrate;
unsigned short x, y; unsigned short x, y;
protected: protected:
int connkey; int connkey;
int sd; int sd;
char loc_sock_path[PATH_MAX]; char loc_sock_path[PATH_MAX];
@ -81,7 +81,7 @@ protected:
char rem_sock_path[PATH_MAX]; char rem_sock_path[PATH_MAX];
struct sockaddr_un rem_addr; struct sockaddr_un rem_addr;
protected: protected:
bool paused; bool paused;
int step; int step;
@ -100,7 +100,7 @@ protected:
CmdMsg msg; CmdMsg msg;
protected: protected:
bool loadMonitor( int monitor_id ); bool loadMonitor( int monitor_id );
bool checkInitialised(); bool checkInitialised();
void updateFrameRate( double fps ); void updateFrameRate( double fps );
@ -109,7 +109,7 @@ protected:
bool checkCommandQueue(); bool checkCommandQueue();
virtual void processCommand( const CmdMsg *msg )=0; virtual void processCommand( const CmdMsg *msg )=0;
public: public:
StreamBase() StreamBase()
{ {
monitor = 0; monitor = 0;

@ -1 +1 @@
Subproject commit e22c1563a51d86aac0d5054beee28b4afb60c802 Subproject commit c3976f1478c681b0bbc132ec3a3e82c3984eeed5