Progress bar

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
oskin
Posts: 84
Joined: Tue May 25, 2004 7:03 pm
Location: Moscow, Russia

Progress bar

Post by oskin »

For convenience of review of events has made progress bar: at the bottom of the image the white bar goes. Unfortunately it noticeably increases usage CPU on a server, as well as in a case, when Scale != Actual. Below a patch adding this possibility. Certainly it should be controlled, for example from Options, but I while did not do it. :)

Code: Select all

--- src/zm_event.cpp.orig       2004-10-30 22:24:22.956803372 +0400
+++ src/zm_event.cpp    2004-10-30 23:03:42.118404007 +0400
@@ -32,6 +32,12 @@
  
 #include "zmf.h"
  
+#if 0
+#define SHOW_PROGRESS_BAR (bool)config.Item( ZM_PROGRESS_BAR )
+#else
+#define SHOW_PROGRESS_BAR true
+#endif
+
 bool Event::initialised = false;
 bool Event::timestamp_on_capture;
 int Event::bulk_frame_interval;
@@ -482,7 +488,7 @@
                                static char filepath[PATH_MAX];
                                snprintf( filepath, sizeof(filepath), capture_file_format, eventpath, id );
  
-                               if ( scale == 100 )
+                               if (( scale == 100 ) && !SHOW_PROGRESS_BAR )
                                {
                                        if ( (fdj = fopen( filepath, "r" )) )
                                        {
@@ -498,7 +504,10 @@
                                {
                                        Image image( filepath );
  
-                                       image.Scale( scale );
+                                       if ( scale != 100 )
+                                               image.Scale( scale );
+                                       if ( SHOW_PROGRESS_BAR )
+                                               image.ProgressBar( id, frames );
  
                                        image.EncodeJpeg( buffer, &n_bytes );
                                }
@@ -628,6 +637,8 @@
                                {
                                        image.Scale( scale );
                                }
+                               if ( SHOW_PROGRESS_BAR )
+                                       image.ProgressBar( id, frames );
  
                                double temp_delta = ((id-last_id)*(db_delta-last_delta))/(db_id-last_id);
                                delta_ms = (unsigned int)((last_delta+temp_delta)*1000);
--- src/zm_image.cpp.orig       2004-10-30 18:33:22.580609987 +0400
+++ src/zm_image.cpp    2004-10-30 23:11:21.149957644 +0400
@@ -1049,3 +1049,16 @@
        buffer = new JSAMPLE[size];
        memcpy( buffer, scale_buffer, size );
 }
+
+void Image::ProgressBar( const unsigned int current, const unsigned int maximum )
+{
+       unsigned int wc = width * colours;
+       for ( unsigned int y = height-4; y < height; y++ ) {
+               unsigned int posc = width * current / (maximum?maximum:1) * colours;
+               if ((y == height-3) || (y == height-2)) {
+                       memset( &buffer[y*wc], WHITE, posc );
+               } else {
+                       memset( &buffer[y*wc], BLACK, posc );
+               }
+       }
+}
--- src/zm_image.h.orig 2004-10-30 18:33:16.510321348 +0400
+++ src/zm_image.h      2004-10-30 23:12:02.951089226 +0400
@@ -224,6 +224,8 @@
        void Rotate( int angle );
  
        void Scale( unsigned int factor );
+
+       void ProgressBar( const unsigned int current, const unsigned int maximum );
 };
  
 #endif // ZM_IMAGE_H
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Thanks for this. It looks interesting, I'll give it a try when I get chance.

I don't know if you have any screenshots of what it looks like but it might help people understand exactly what they would see.

Phil,
oskin
Posts: 84
Joined: Tue May 25, 2004 7:03 pm
Location: Moscow, Russia

Post by oskin »

http://oskin.ru/pics/progressbar.jpg
Sorry, I now cannot make a picture of better quality.

I have thought of such variant: after the termination of record of event it was - possible to start procedure, which in a background will add progress bar (accordingly having increased height of the image) to all saved frames. It will allow to have progress bar not spending many resources. Still it is possible to add a scale with marks of "active frames".
Post Reply