1 #ifndef MTF_OBJ_UTILS_H 2 #define MTF_OBJ_UTILS_H 8 #include "opencv2/core/core.hpp" 9 #include "mtf/Utilities/inputUtils.h" 11 #include <visp3/core/vpColor.h> 23 cv::Point2d min_point;
24 cv::Point2d max_point;
34 void updateCornerMat();
35 void updateCornerPoints();
36 void operator*=(
double resize_factor);
39 typedef std::shared_ptr<ObjStruct> ObjStructPtr;
42 inline void getClickedPoint(
int mouse_event,
int x,
int y,
int flags,
void* param);
50 ObjUtils(
const vector_s &_obj_cols = vector_s(),
51 double _resize_factor = 1.0);
53 const cv::Scalar &getCol(
int col_id){
54 return obj_cols[col_id % no_of_cols];
56 const cv::Scalar &getCol(
const std::string &col_name){
57 return col_rgb.at(col_name);
59 void getCols(vector<cv::Scalar> &cols) {
63 const vpColor &getColVp(
int col_id){
64 return obj_cols_vp[col_id % no_of_cols_vp];
66 const vpColor &getColVp(
const std::string &col_name){
67 return col_rgb_vp.at(col_name);
69 void getCols(vector<vpColor> &cols) {
76 bool addRectObject(
InputBase *input,
string selection_window,
77 int line_thickness = 2,
int patch_size = 0);
81 bool addQuadObject(
InputBase *input,
string selection_window,
82 int line_thickness = 2);
84 bool selectObjects(
const cv::Mat &img,
int no_of_objs,
85 int patch_size = 0,
int line_thickness = 1,
int write_objs = 0,
bool sel_quad_obj =
false,
86 const char* filename =
"selected_objects.txt");
87 bool selectObjects(
InputBase *input,
int no_of_objs,
int patch_size = 0,
88 int line_thickness = 1,
int write_objs = 0,
bool sel_quad_obj =
false,
89 const char* filename =
"selected_objects.txt");
91 bool addRectObjectVP(
InputBase *input,
string selection_window,
92 int line_thickness = 2,
int patch_size = 0);
93 bool addQuadObjectVP(
InputBase *input,
string selection_window,
94 int line_thickness = 2);
96 bool selectObjectsVP(
const cv::Mat &img,
int no_of_objs,
97 int patch_size = 0,
int line_thickness = 1,
int write_objs = 0,
bool sel_quad_obj =
false,
98 const char* filename =
"selected_objects.txt");
99 bool selectObjectsVP(
InputBase *input,
int no_of_objs,
int patch_size = 0,
100 int line_thickness = 1,
int write_objs = 0,
bool sel_quad_obj =
false,
101 const char* filename =
"selected_objects.txt");
103 void writeObjectsToFile(
int no_of_objs,
104 const char* filename =
"sel_objs/selected_objects.txt");
105 bool readObjectFromGT(
string source_name,
string source_path,
int n_frames,
106 int _init_frame_id = 0,
bool use_opt_gt =
false,
string opt_gt_ssm =
"2",
107 bool _use_reinit_gt =
false,
bool _invert_seq =
false,
int debug_mode = 0);
108 bool getObjStatus()
const{
return !init_objects.empty(); }
109 const ObjStruct &getObj(
int obj_id = 0)
const{
110 return init_objects.size() == 1 ? init_objects[0] : init_objects[obj_id];
112 const cv::Mat &getGT(
int frame_id,
int _reinit_frame_id = -1);
113 const cv::Mat &getReinitGT(
int frame_id,
int _reinit_frame_id = -1);
114 const vector<cv::Mat> &getGT(){
return ground_truth; }
116 return use_reinit_gt ? ground_truth.size() + reinit_frame_id : ground_truth.size();
118 bool readGT(
string source_name,
string source_path,
119 int n_frames = 1,
int init_frame_id = 0,
int debug_mode = 0,
120 bool use_opt_gt =
false,
string opt_gt_ssm =
"2");
121 bool readReinitGT(
string source_name,
string source_path,
122 int _reinit_frame_id,
int _n_frames,
bool use_opt_gt =
false,
123 string opt_gt_ssm =
"2");
124 bool readObjectsFromFile(
int no_of_objs,
125 const char* filename =
"sel_objs/selected_objects.txt",
int debug_mode = 0);
126 cv::Point getMeanPoint(cv::Point *pt_array,
int no_of_points);
127 void cornersToPoint2D(cv::Point2d(&cv_corners)[4],
const cv::Mat &cv_corners_mat);
130 const std::map<std::string, cv::Scalar> col_rgb;
132 const std::map<std::string, vpColor> col_rgb_vp;
134 vector<ObjStruct> init_objects;
135 vector<cv::Mat> ground_truth;
136 vector<cv::Mat> reinit_ground_truth;
137 int init_frame_id, reinit_frame_id;
140 string reinit_gt_filename;
141 vector<cv::Scalar> obj_cols;
144 vector<vpColor> obj_cols_vp;
147 const double resize_factor;
148 const bool resized_images;
151 void readReinitGT(
int _reinit_frame_id);
152 const vector<cv::Mat> &getReinitGT(){
return reinit_ground_truth; }
utility functions to obtain initial object location for tracking - either read from a ground truth fi...
Definition: objUtils.h:48
simple structure to store an object read from ground truth or selected by the user; requires that the...
Definition: objUtils.h:22
basic functions for preprocessing the raw input image using filtering, resizing and histogram equaliz...
Definition: histUtils.h:20