Created
October 12, 2024 23:46
-
-
Save masouduut94/c0dfd4e2954b54c507d5c19ecb32ee12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef EVALUATOR_H // Include guards to prevent double inclusion | |
#define EVALUATOR_H | |
#include <string> | |
#include <vector> | |
class BoundingBox { | |
public: | |
// Constructor | |
BoundingBox(int annotation_id, int image_id, int category_id, int x1, int y1, int w, int h); | |
// Methods to determine true positives, false positives, etc. | |
bool is_true_positive_or_false_positive(const std::vector<BoundingBox>& ground_truth_boxes, float iou_threshold = 0.5) const; | |
bool is_false_negative(const std::vector<BoundingBox>& predicted_boxes, float iou_threshold = 0.5) const; | |
// Method to calculate IoU | |
float calculate_iou(const BoundingBox& other_box) const; | |
// Data members for bounding box attributes | |
int annotation_id; | |
int image_id; | |
int category_id; | |
int x1, y1, x2, y2, w, h; | |
}; | |
class CppEvaluator { | |
public: | |
CppEvaluator(const std::string& ground_truth_json, const std::string& predictions_json); | |
std::tuple<std::vector<int>, std::vector<int>, std::vector<int>> evaluate(); | |
std::vector<BoundingBox> ground_truth_boxes; | |
std::vector<BoundingBox> predicted_boxes; | |
}; | |
#endif // EVALUATOR_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment