Skip to content

Commit

Permalink
fix macro bugs and typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
wei.wei committed Nov 16, 2023
1 parent b010a58 commit d621f8c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 25 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Aruco Marker Navigation

Based on opencv aruco marker, we retrieve the `world2cam` rotation angles and translations for the nearest `id` marker.
This can help us on navigating the predefined road and give a warning for departure.
This can help us on navigating the predefined road and give a warning for departure.

## Linux and Windows OpenCV Version Difference
For `linux`, the OpenCV version is: 4.5.4, where `windows` is: 4.8.0.
15 changes: 8 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "src/rscvcapture.h"
#include <filesystem>
#include <vector>
#include <opencv2/core/version.hpp>
using namespace aruconavi;
namespace fs = std::filesystem;
using namespace std;
Expand Down Expand Up @@ -41,12 +42,12 @@ int main() {
// cv::imshow("detected coordinate system", image_copy);
// cv::waitKey(0);
// cv::destroyAllWindows();
bool status = rs_with_cv_capture(1280, 720);
if (status) {
cout << "launch succeed!" << endl;
} else {
cout << "launch failed!" << endl;
}
// std::cout << "OpenCV version: " << CV_VERSION << std::endl;
// bool status = rs_with_cv_capture(1280, 720);
// if (status) {
// cout << "launch succeed!" << endl;
// } else {
// cout << "launch failed!" << endl;
// }
std::cout << "OpenCV version: " << CV_VERSION << std::endl;
return 0;
}
8 changes: 6 additions & 2 deletions src/calculate_angles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ namespace aruconavi {
int status = -1;
status = detect_left_right_departure(id);
if (status == 3) {
std::cout << RED << "WARNING: " << "you are left drifted, please make a right turn!" << std::endl;
std::cout << RED << "WARNING: "
<< "you are left drifted, please make a right turn!"
<< std::endl;
}
if (status == 4) {
std::cout << RED << "WARNING: " << "you are right drifted, please make a left turn!" << std::endl;
std::cout << RED << "WARNING: "
<< "you are right drifted, please make a left turn!"
<< std::endl;
}
}
} // namespace aruconavi
5 changes: 5 additions & 0 deletions src/detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@

namespace aruconavi {
std::pair<std::vector<int>, std::vector<std::vector<cv::Point2f>>>
#if defined(_WIN32) || defined(_WIN64)
detect_markers(cv::Mat& image,
cv::aruco::PredefinedDictionaryType aruco_dict_info) {
#else
detect_markers(cv::Mat& image,
cv::aruco::PREDEFINED_DICTIONARY_NAME aruco_dict_info) {
#endif
cv::Mat gray;
cv::cvtColor(image, gray, cv::COLOR_BGR2GRAY);
#if defined(_WIN32) || defined(_WIN64)
Expand Down
21 changes: 12 additions & 9 deletions src/drawfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ namespace aruconavi {
}
}

void Painter::print_message(const Eigen::Vector3f& ypr, const Eigen::Vector3f& translation) {
std::cout << "rotation angles are: " << "\n" <<
"yaw: " << ypr(0) << "\n" <<
"pitch: " << ypr(1) << "\n" <<
"roll: " << ypr(2) << std::endl;
std::cout << "translation offset is(in meters): " << "\n" <<
"x axis: " << translation(0) << "\n" <<
"y axis: " << translation(1) << "\n" <<
"z axis: " << translation(2) << std::endl;
void Painter::print_message(const Eigen::Vector3f& ypr,
const Eigen::Vector3f& translation) {
std::cout << "rotation angles are: "
<< "\n"
<< "yaw: " << ypr(0) << "\n"
<< "pitch: " << ypr(1) << "\n"
<< "roll: " << ypr(2) << std::endl;
std::cout << "translation offset is(in meters): "
<< "\n"
<< "x axis: " << translation(0) << "\n"
<< "y axis: " << translation(1) << "\n"
<< "z axis: " << translation(2) << std::endl;
std::cout << "===============================" << std::endl;
}

Expand Down
7 changes: 4 additions & 3 deletions src/drawfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ namespace aruconavi {
const Eigen::Vector<float, 5>& dist_coef,
const cv::Vec3d& rvec, const cv::Vec3d& tvec);
void draw_detected_markers(
const std::pair<std::vector<int>, std::vector<std::vector<cv::Point2f>>>&
pairs);
void print_message(const Eigen::Vector3f& ypr, const Eigen::Vector3f& translation);
const std::pair<std::vector<int>,
std::vector<std::vector<cv::Point2f>>>& pairs);
void print_message(const Eigen::Vector3f& ypr,
const Eigen::Vector3f& translation);
// void draw_text();
~Painter() = default;
};
Expand Down
2 changes: 1 addition & 1 deletion src/rscapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ namespace aruconavi {
return false;
}
}
}
} // namespace aruconavi
5 changes: 3 additions & 2 deletions src/rscvcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace aruconavi {
Mat image_out;
while (waitKey(1) < 0 &&
getWindowProperty(win_name, WND_PROP_AUTOSIZE) >= 0) {
rs2::frameset data = pipe.wait_for_frames(); // wait for next set of frames from the camera
rs2::frameset data = pipe.wait_for_frames(); // wait for next set of
// frames from the camera
auto rgb = data.get_color_frame();

// query frame size (width and height)
Expand Down Expand Up @@ -61,4 +62,4 @@ namespace aruconavi {
return false;
}
}
}
} // namespace aruconavi

0 comments on commit d621f8c

Please sign in to comment.