Remove unexpected files that were added

This commit is contained in:
Linwood-F 2015-07-23 15:15:57 -04:00
parent b88403cd41
commit 3544fbd0a8
4 changed files with 23 additions and 94 deletions

View File

@ -67,14 +67,6 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
if ( !initialised ) if ( !initialised )
Initialise(); Initialise();
// >>> Real time image extrat settings <<< these need to go in conf options
UpldCount=0;
strcpy(UpldPath,"/home/ferguson/ToUpload");
UpldWriteEvery=600;
UpldWriteEveryAlarm=2;
std::string notes; std::string notes;
createNotes( notes ); createNotes( notes );
@ -357,42 +349,28 @@ bool Event::SendFrameImage( const Image *image, bool alarm_frame )
bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame ) bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame )
{ {
bool toUpld=false; if ( config.timestamp_on_capture )
char UpldFile[PATH_MAX];
char UpldFileRename[PATH_MAX];
if( ( UpldCount++ % (alarm_frame ? UpldWriteEveryAlarm : UpldWriteEvery) ) == 0) // notice this grabs frame #1 so it gets the first of every event (zero count = frame 1)
{ {
toUpld=true; if ( !config.opt_frame_server || !SendFrameImage( image, alarm_frame) )
char tmbuf[64], buf[64]; {
strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d-%H-%M-%S", localtime(&(timestamp.tv_sec))); if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) )
snprintf(buf, sizeof buf, "%s-%06d", tmbuf,(int)(timestamp.tv_usec)); image->WriteJpeg( event_file, config.jpeg_alarm_file_quality );
snprintf(UpldFile, sizeof(UpldFile),"%s/%s-%06d_%s_%s.jpg_saving",UpldPath, tmbuf,(int)(timestamp.tv_usec),this->monitor->Name(),alarm_frame?"Alarm":"Periodic"); else
snprintf(UpldFileRename, sizeof(UpldFile),"%s/%s-%06d_%s_%s.jpg", UpldPath, tmbuf,(int)(timestamp.tv_usec),this->monitor->Name(),alarm_frame?"Alarm":"Periodic"); image->WriteJpeg( event_file );
} }
}
Image* ImgToWrite; else
Image ts_image( *image ); {
Image ts_image( *image );
if ( config.timestamp_on_capture ) // stash the image we plan to use in another pointer regardless if timestamped. monitor->TimestampImage( &ts_image, &timestamp );
{ if ( !config.opt_frame_server || !SendFrameImage( &ts_image, alarm_frame) )
monitor->TimestampImage( &ts_image, &timestamp ); {
ImgToWrite=&ts_image; if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) )
} ts_image.WriteJpeg( event_file, config.jpeg_alarm_file_quality );
else else
ImgToWrite=image; ts_image.WriteJpeg( event_file );
if ( !config.opt_frame_server || !SendFrameImage( ImgToWrite, alarm_frame) )
{
int thisquality = ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) ? config.jpeg_alarm_file_quality : 0 ; // quality to use
ImgToWrite->WriteJpeg( event_file, thisquality, timestamp );
if(toUpld)
{ // Because these are for real-time use and may be grabbed as they are being written, write under one name then rename
ImgToWrite->WriteJpeg(UpldFile, thisquality, timestamp);
if(rename(UpldFile, UpldFileRename)!=0)
Error ("Failure to rename real time capture file %s to %s, ignored",UpldFile, UpldFileRename);
} }
} }
return( true ); return( true );
} }
@ -907,7 +885,7 @@ void EventStream::processCommand( const CmdMsg *msg )
} }
// If we are in single event mode and at the last frame, replay the current event // If we are in single event mode and at the last frame, replay the current event
if ( (mode == MODE_SINGLE) && ((unsigned int)curr_frame_id == event_data->frame_count) ) if ( (mode == MODE_SINGLE) && (curr_frame_id == event_data->frame_count) )
curr_frame_id = 1; curr_frame_id = 1;
replay_rate = ZM_RATE_BASE; replay_rate = ZM_RATE_BASE;

View File

@ -59,12 +59,6 @@ protected:
protected: protected:
static int sd; static int sd;
private:
int UpldCount;
char UpldPath[PATH_MAX];
int UpldWriteEvery;
int UpldWriteEveryAlarm;
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;

View File

@ -787,22 +787,7 @@ bool Image::ReadJpeg( const char *filename, unsigned int p_colours, unsigned int
return( true ); return( true );
} }
// Multiple calling formats to permit inclusion (or not) of both quality_override and timestamp (exif), with suitable defaults. bool Image::WriteJpeg( const char *filename, int quality_override ) const
bool Image::WriteJpeg( const char *filename, int quality_override) const
{
return Image::WriteJpeg(filename, quality_override, (timeval){0,0});
}
bool Image::WriteJpeg( const char *filename) const
{
return Image::WriteJpeg(filename, 0, (timeval){0,0});
}
bool Image::WriteJpeg( const char *filename, struct timeval timestamp ) const
{
return Image::WriteJpeg(filename,0,timestamp);
}
bool Image::WriteJpeg( const char *filename, int quality_override, struct timeval timestamp ) const
{ {
if ( config.colour_jpeg_files && colours == ZM_COLOUR_GRAY8 ) if ( config.colour_jpeg_files && colours == ZM_COLOUR_GRAY8 )
{ {
@ -810,6 +795,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override, struct timeva
temp_image.Colourise( ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); temp_image.Colourise( ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB );
return( temp_image.WriteJpeg( filename, quality_override ) ); return( temp_image.WriteJpeg( filename, quality_override ) );
} }
int quality = quality_override?quality_override:config.jpeg_file_quality; int quality = quality_override?quality_override:config.jpeg_file_quality;
struct jpeg_compress_struct *cinfo = jpg_ccinfo[quality]; struct jpeg_compress_struct *cinfo = jpg_ccinfo[quality];
@ -901,30 +887,6 @@ bool Image::WriteJpeg( const char *filename, int quality_override, struct timeva
jpeg_write_marker( cinfo, JPEG_COM, (const JOCTET *)text, strlen(text) ); jpeg_write_marker( cinfo, JPEG_COM, (const JOCTET *)text, strlen(text) );
} }
if(timestamp.tv_sec)
{
#define EXIFTIMES_MS_OFFSET 0x36 // three decimal digits for milliseconds
#define EXIFTIMES_MS_LEN 0x03
#define EXIFTIMES_OFFSET 0x3E // 19 characters format '2015:07:21 13:14:45' not including quotes
#define EXIFTIMES_LEN 0x13 // = 19
#define EXIF_CODE 0xE1
char timebuf[64], msbuf[64];
strftime(timebuf, sizeof timebuf, "%Y:%m:%d %H:%M:%S", localtime(&(timestamp.tv_sec)));
snprintf(msbuf, sizeof msbuf, "%06d",(int)(timestamp.tv_usec)); // we only use milliseconds because that's all defined in exif, but this is the whole microseconds because we have it
unsigned char exiftimes[82] = {
0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00,
0x69, 0x87, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x03, 0x90, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x91, 0x92,
0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00 };
memcpy(&exiftimes[EXIFTIMES_OFFSET], timebuf,EXIFTIMES_LEN);
memcpy(&exiftimes[EXIFTIMES_MS_OFFSET],msbuf ,EXIFTIMES_MS_LEN); // first character after the decimal point
jpeg_write_marker (cinfo, EXIF_CODE, (const JOCTET *)exiftimes, sizeof(exiftimes) );
}
JSAMPROW row_pointer; /* pointer to a single row */ JSAMPROW row_pointer; /* pointer to a single row */
int row_stride = cinfo->image_width * colours; /* physical row width in buffer */ int row_stride = cinfo->image_width * colours; /* physical row width in buffer */
while ( cinfo->next_scanline < cinfo->image_height ) while ( cinfo->next_scanline < cinfo->image_height )

View File

@ -204,12 +204,7 @@ public:
bool WriteRaw( const char *filename ) const; bool WriteRaw( const char *filename ) const;
bool ReadJpeg( const char *filename, unsigned int p_colours, unsigned int p_subpixelorder); bool ReadJpeg( const char *filename, unsigned int p_colours, unsigned int p_subpixelorder);
bool WriteJpeg( const char *filename, int quality_override=0 ) const;
bool WriteJpeg ( const char *filename) const;
bool WriteJpeg ( const char *filename, int quality_override ) const;
bool WriteJpeg ( const char *filename, struct timeval timestamp ) const;
bool WriteJpeg ( const char *filename, int quality_override, struct timeval timestamp ) const;
bool DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, unsigned int p_colours, unsigned int p_subpixelorder); bool DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, unsigned int p_colours, unsigned int p_subpixelorder);
bool EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override=0 ) const; bool EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override=0 ) const;