INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

histogram2d.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010  
00011 #ifndef HISTOGRAM2D_H
00012 #define HISTOGRAM2D_H
00013 
00014 #include <string>
00015 #include <vector>
00016 
00017 namespace delaymon
00018 {
00019 
00020 // not thread-safe
00021 class Histogram2d
00022 {
00023 public:
00024     // start, end, stride in [ms]
00025     // stride must be positive
00026     // histogram must have at least 1 bin
00027     Histogram2d( int startEdge, int endEdge, int stride, const std::string& fileprefix );
00028     ~Histogram2d();
00029 
00030     void addValue( int valueX, int valueY );
00031 
00032     const std::vector<std::vector<int> > &counters() const { return counters_; };
00033 
00034     // -inf and +inf are not included even though those values are counted
00035     std::vector<int> edges() const;
00036 
00037     std::string toString() const;
00038 
00039 private:
00040 
00041     
00042     // the bins are the same for both dimensions and defined as follows:
00043     //  [-inf, start)
00044     //  [start, start+stride)
00045     //  [start+strid, start+2*stride)
00046     //  ...
00047     //  [start+N-1*stride, start+N*stride)
00048     //  [start+N*stride, +inf)
00049     //
00050     // where (start+N*stride) <= end
00051     std::vector<std::vector<int> > counters_;
00052     int start_;
00053     int end_;
00054     int stride_;
00055 
00056     // bins per dimension (same for both dimensions)
00057     int binsPerDim_;
00058     
00059     void bin( int valueX, int valueY, int &indexX, int &indexY );
00060 
00061     std::ofstream *file_;
00062 };
00063 
00064 } // namespace
00065 
00066 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5