CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Classes | Public Member Functions | List of all members
cavapa_gui::Results Class Reference

The class holds the calculation results for each frame. More...

#include <results.h>

Public Member Functions

FrameStats addFrame (FrameTime time, const std::vector< cavapa::Sightings > &sightings)
 Adds the new frame to the results. More...
 
void clear ()
 Deletes all the stored calculation results.
 
bool empty () const
 Checks if the are no results. More...
 
bool exportToCSV (const ExportOptions &options) const
 Exports the results to the CSV file. More...
 
unsigned int getCount () const
 Returns the number of the frames saved. More...
 
FrameTime getFirstFrameTime () const
 Retrieves the time of the first frame in Results. More...
 
int getFrameNumber (FrameTime time) const
 Returns the frame number for the given FrameTime. More...
 
std::vector< cavapa::Sightings > getSightings (FrameTime time) const
 Retrieves the sighting information from the frame. More...
 
std::vector< FrameStatsgetStatistics (FrameTime start, FrameTime stop, int points) const
 Returns the calculation statistics from the given period. More...
 
bool load (const std::string &path)
 Loads the calculation results from the file. More...
 
bool save (const std::string &path) const
 Saves the calculation results to the file. More...
 

Detailed Description

The class holds the calculation results for each frame.

It keeps the results in order and provides export, save, load and averaging functions for the other parts of the program.

The current results can be removed with clear(). New frames can be inserted with addFrame() which calculates the total activity and the sighting count for the frame.

The frame specific results can be retrieved with getStatistics() or they can be exported to the CSV file with exportToCSV(). The Results and sightings can also be saved to the file and loaded later.

Author
Petri Partanen
Remarks
The save file format is as follows:
 frame_count (i) : uint32_t
 [FRAME 1]
     frame_stats   : FrameStats
     cameras (n)   : uint32_t
     sightings (m) : uint32_t

     [CAMERA 1]
         sighting_count (j) : uint32_t
     [CAMERA 2]
         sighting_count     : uint32_t
     [CAMERA 3]
     ...
     [CAMERA n]

     [CAMERA 1 SIGHTINGS]
         [SIGHTING 1]
             sighting      : SightingFixed
         [SIGHTING 2]
             sighting      : SightingFixed
         [SIGHTING 3]
         ...
         [SIGHTING j]
     [CAMERA 2 SIGHTINGS]
     ...
     [SIGHTINGS m]
 [FRAME 2]
 ...
 [FRAME i]

Member Function Documentation

FrameStats cavapa_gui::Results::addFrame ( FrameTime  time,
const std::vector< cavapa::Sightings > &  sightings 
)

Adds the new frame to the results.

This also calculates the frame's statistics and returns them.

Parameters
timeA time of the frame.
sightingsThe sightings on the frame.
Returns
The statistics of the new frame.
Remarks
Currently Results class does not sort the frames in any way, so the frame's time must have a later timestamp than the previous frame.
bool cavapa_gui::Results::empty ( ) const
inline

Checks if the are no results.

Returns
True if no results were saved or false otherwise.
bool cavapa_gui::Results::exportToCSV ( const ExportOptions options) const

Exports the results to the CSV file.

It exports the basic frame information to the file in a CSV format. Any old data will be overwritten, unless APPEND flag is set.

Parameters
optionsThe options for the export.
Returns
True if the file was written succesfully or false otherwise.
unsigned int cavapa_gui::Results::getCount ( ) const
inline

Returns the number of the frames saved.

Returns
The total frame count.
FrameTime cavapa_gui::Results::getFirstFrameTime ( ) const
inline

Retrieves the time of the first frame in Results.

Returns
The frametime of the first frame. It will return 0 if none exists.
int cavapa_gui::Results::getFrameNumber ( FrameTime  time) const

Returns the frame number for the given FrameTime.

Parameters
timeFrameTime to look for.
Returns
The frame number for the given FrameTime or a negative value if failed.
std::vector< Sightings > cavapa_gui::Results::getSightings ( FrameTime  time) const

Retrieves the sighting information from the frame.

Parameters
timeThe frame time.
Returns
The sightings from the frame.

TODO: Actually return something.

vector< FrameStats > cavapa_gui::Results::getStatistics ( FrameTime  start,
FrameTime  stop,
int  points 
) const

Returns the calculation statistics from the given period.

It can be used to return the frame statistics from a given period. The average values are calculated automatically from between the returned period points.

Parameters
startThe period start time. If 0, the period will start from the first possible frame.
stopThe period end time. If 0, the period will end at the last possible frame.
pointsThe number of points to be returned from the specified period.
Returns
The calculation results from a given period. There will be from 0 to 'points' number of FrameStats returned.
bool cavapa_gui::Results::load ( const std::string &  path)

Loads the calculation results from the file.

Parameters
pathThe full file path.
Returns
True if loading was successful or false otherwise.
Remarks
The old results will be destroyed.
bool cavapa_gui::Results::save ( const std::string &  path) const

Saves the calculation results to the file.

Parameters
pathThe full file path.
Returns
True if saving was successful or false otherwise.

The documentation for this class was generated from the following files: