31 #include <opencv2/core/core.hpp>
32 #include <opencv2/highgui/highgui.hpp>
34 #include <boost/date_time/posix_time/posix_time.hpp>
35 #include <boost/filesystem.hpp>
46 #if ROS_AVAILABLE == 1
59 int main(
int argc,
char **argv) {
62 std::string config_path =
"unset_path.txt";
64 config_path = argv[1];
67 #if ROS_AVAILABLE == 1
70 auto nh = std::make_shared<ros::NodeHandle>(
"~");
71 nh->param<std::string>(
"config_path", config_path, config_path);
75 auto parser = std::make_shared<ov_core::YamlParser>(config_path,
false);
76 #if ROS_AVAILABLE == 1
77 parser->set_node_handler(nh);
81 std::string verbosity =
"INFO";
82 parser->parse_config(
"verbosity", verbosity);
89 int fast_threshold = 10;
93 double knn_ratio = 0.85;
94 bool do_downsizing =
false;
95 bool use_stereo =
false;
96 parser->parse_config(
"num_pts", num_pts,
false);
97 parser->parse_config(
"num_aruco", num_aruco,
false);
98 parser->parse_config(
"clone_states",
clone_states,
false);
99 parser->parse_config(
"fast_threshold", fast_threshold,
false);
100 parser->parse_config(
"grid_x", grid_x,
false);
101 parser->parse_config(
"grid_y", grid_y,
false);
102 parser->parse_config(
"min_px_dist", min_px_dist,
false);
103 parser->parse_config(
"knn_ratio", knn_ratio,
false);
104 parser->parse_config(
"do_downsizing", do_downsizing,
false);
105 parser->parse_config(
"use_stereo", use_stereo,
false);
109 std::string histogram_method_str =
"HISTOGRAM";
110 parser->parse_config(
"histogram_method", histogram_method_str,
false);
111 if (histogram_method_str ==
"NONE") {
113 }
else if (histogram_method_str ==
"HISTOGRAM") {
115 }
else if (histogram_method_str ==
"CLAHE") {
118 printf(
RED "invalid feature histogram specified:\n" RESET);
120 printf(
RED "\t- HISTOGRAM\n" RESET);
122 std::exit(EXIT_FAILURE);
129 PRINT_DEBUG(
"grid size: %d x %d\n", grid_x, grid_y);
130 PRINT_DEBUG(
"fast threshold: %d\n", fast_threshold);
131 PRINT_DEBUG(
"min pixel distance: %d\n", min_px_dist);
132 PRINT_DEBUG(
"downsize aruco image: %d\n", do_downsizing);
135 std::unordered_map<size_t, std::shared_ptr<CamBase>> cameras;
136 for (
int i = 0; i < 2; i++) {
137 Eigen::Matrix<double, 8, 1> cam0_calib;
138 cam0_calib << 1, 1, 0, 0, 0, 0, 0, 0;
139 std::shared_ptr<CamBase> camera_calib = std::make_shared<CamRadtan>(100, 100);
140 camera_calib->set_value(cam0_calib);
141 cameras.insert({i, camera_calib});
145 extractor =
new TrackKLT(cameras, num_pts, num_aruco, !use_stereo, method, fast_threshold, grid_x, grid_y, min_px_dist);
154 cv::VideoCapture cap;
165 double current_time = 0.0;
168 #if ROS_AVAILABLE == 1
177 current_time += 1.0 / 30.0;
184 if (cv::waitKey(10) == 27)
188 if (frame.channels() != 1)
189 cv::cvtColor(frame, frame, cv::COLOR_RGB2GRAY);
195 message.
images.push_back(frame);
196 message.
masks.push_back(cv::Mat::zeros(cv::Size(frame.cols, frame.rows), CV_8UC1));
200 cv::Mat img_active, img_history;
205 cv::imshow(
"Active Tracks", img_active);
206 cv::imshow(
"Track History", img_history);
211 std::vector<std::shared_ptr<Feature>> feats_lost = database->features_not_containing_newer(current_time);
214 for (
size_t i = 0; i < feats_lost.size(); i++) {
217 for (
auto const &pair : feats_lost[i]->timestamps) {
218 total_meas += (int)pair.second.size();
221 feats_lost[i]->to_delete =
true;
232 std::vector<std::shared_ptr<Feature>> feats_marg = database->features_containing(margtime);
234 for (
size_t i = 0; i < feats_marg.size(); i++) {
235 feats_marg[i]->to_delete =
true;