From 85750596660f3354ea89735fb48ba7b54989f6ad Mon Sep 17 00:00:00 2001 From: Micaela Verucchi Date: Mon, 6 Apr 2020 18:35:52 +0200 Subject: [PATCH] Add again evalutation.h Signed-off-by: Micaela Verucchi --- include/tkDNN/evaluation.h | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 include/tkDNN/evaluation.h diff --git a/include/tkDNN/evaluation.h b/include/tkDNN/evaluation.h new file mode 100644 index 0000000..98a4166 --- /dev/null +++ b/include/tkDNN/evaluation.h @@ -0,0 +1,61 @@ +#ifndef EVALUATION_H +#define EVALUATION_H + +#include +#include +#include + +#include + +#include "tkdnn.h" + +namespace tk { namespace dnn { +struct BoundingBox : public tk::dnn::box +{ + friend std::ostream& operator<<(std::ostream& os, const BoundingBox& bb); + int uniqueTruthIndex = -1; + int truthFlag = 0; + float maxIoU = 0; + + void clear(); +}; + +std::ostream& operator<<(std::ostream& os, const BoundingBox& bb); +bool boxComparison (const BoundingBox& a,const BoundingBox& b) ; + +struct Frame +{ + std::string lFilename; + std::string iFilename; + std::vector gt; + std::vector det; + + void print() const; +}; + +struct PR +{ + double precision = 0; + double recall = 0; + int tp = 0, fp = 0, fn = 0; + + void print(); +}; + +float boxOverlap(float x1, float w1, float x2, float w2); +float boxIntersection(const BoundingBox &a, const BoundingBox &b); +float boxUnion(const BoundingBox &a, const BoundingBox &b); +float boxIoU(const BoundingBox &a, const BoundingBox &b); + +void readmAPParams(char* config_filename, int& classes, int& map_points, + int& map_levels, float& map_step, float& IoU_thresh, + float& conf_thresh, bool& verbose); + +double computeMap(std::vector &images,const int classes,const float IoU_thresh, const float conf_thresh=0.3, const int map_points=101, const bool verbose=false); +double computeMapNIoULevels(std::vector &images,const int classes,const float i_IoU_thresh=0.5, const float conf_thresh=0.3, const int map_points=101, const float map_step=0.05, const int map_levels=10, const bool verbose=false, const bool write_on_file = false, std::string net = ""); + +void computeTPFPFN(std::vector &images,const int classes,const float IoU_thresh=0.5, const float conf_thresh=0.3, bool verbose=false, const bool write_on_file=false, std::string net=""); + +}} +#endif /*EVALUATION_H*/ +