/** 
* @file LocalizationAnalysis.h
* @brief Some methods for localization analysis
* @author Erik Rodner
* @date 09/01/2008

*/
#ifndef LOCALIZATIONANALYSISINCLUDE
#define LOCALIZATIONANALYSISINCLUDE

#include <vector>
#include <map>

#include "LocalizationResult.h"


namespace OBJREC {

/** Some methods for localization analysis */
class LocalizationAnalysis
{

    protected:
		double trapezoidArea ( double x1, double y1, double x2, double y2 );

    public:
  
		/** simple constructor */
		LocalizationAnalysis();
		  
		/** simple destructor */
		virtual ~LocalizationAnalysis();
	  
		void matchResults ( LocalizationResult *l, 
					const LocalizationResult *l_gt,
					std::vector< std::pair<double, int> > & results,
					double matchThreshold = 0.3,
					bool rejectMultipleDetections = true);

		void calcRecallPrecisionCurve ( const std::vector< std::pair<double, int> > & results_unsorted,
						  int count_positives,
						  std::vector<double> & thresholdsv,
						  std::vector<double> & recallv,
						  std::vector<double> & precisionv );

		double calcAreaUnderROC ( const std::vector<double> & fprate,
				const std::vector<double> & tprate );

		void calcROCCurve ( const std::vector< std::pair<double, int> > & results_unsorted,
								  int count_positives,
								  int count_negatives,
								  std::vector<double> & thresholdsv,
								  std::vector<double> & fprates,
								  std::vector<double> & tprates );

		/** calculates the 11-point estimate of the average precision given
			recall and precision values (used for PASCAL VOC) */
		double calcAveragePrecision ( const std::vector<double> & recall,
					  const std::vector<double> & precision );

		/** calculates a precise estimate of the average precision, given
			recall and precision values */
		double calcAveragePrecisionPrecise ( const std::vector<double> & recall,
					  const std::vector<double> & precision );

};


} // namespace

#endif
