Commit f4457dced37beb7890425b1f3cef028c9cdd2fe3

Authored by Josh Klontz
1 parent cf1ec399

TemplateCountGallery now statGallery

Showing 1 changed file with 16 additions and 12 deletions
openbr/plugins/gallery.cpp
... ... @@ -27,6 +27,7 @@
27 27 #include "openbr_internal.h"
28 28  
29 29 #include "openbr/core/bee.h"
  30 +#include "openbr/core/common.h"
30 31 #include "openbr/core/opencvutils.h"
31 32 #include "openbr/core/qtutils.h"
32 33  
... ... @@ -834,22 +835,26 @@ BR_REGISTER(Gallery, googleGallery)
834 835  
835 836 /*!
836 837 * \ingroup galleries
837   - * \brief Count the number of templates.
  838 + * \brief Print template statistics.
838 839 * \author Josh Klontz \cite jklontz
839 840 */
840   -class TemplateCountGallery : public Gallery
  841 +class statGallery : public Gallery
841 842 {
842 843 Q_OBJECT
843   - int count;
  844 + QList<int> bytes;
844 845  
845   - ~TemplateCountGallery()
  846 + ~statGallery()
846 847 {
847   - printf("%d\n", count);
848   - }
  848 + int emptyTemplates = 0;
  849 + for (int i=bytes.size()-1; i>=0; i--)
  850 + if (bytes[i] == 0) {
  851 + bytes.removeAt(i);
  852 + emptyTemplates++;
  853 + }
849 854  
850   - void init()
851   - {
852   - count = 0;
  855 + double bytesMean, bytesStdDev;
  856 + Common::MeanStdDev(bytes, &bytesMean, &bytesStdDev);
  857 + printf("Empty Templates: %d/%d\nBytes/Template: %.4g +/- %.4g\n", emptyTemplates, emptyTemplates+bytes.size(), bytesMean, bytesStdDev);
853 858 }
854 859  
855 860 TemplateList readBlock(bool *done)
... ... @@ -860,12 +865,11 @@ class TemplateCountGallery : public Gallery
860 865  
861 866 void write(const Template &t)
862 867 {
863   - (void) t;
864   - count++;
  868 + bytes.append(t.bytes());
865 869 }
866 870 };
867 871  
868   -BR_REGISTER(Gallery, TemplateCountGallery)
  872 +BR_REGISTER(Gallery, statGallery)
869 873  
870 874 } // namespace br
871 875  
... ...