21 #include <opencv2/core/core.hpp> 22 #include <opencv2/highgui/highgui.hpp> 35 switch (config.thresholdMethod) {
48 std::vector<aruco::Marker> markers;
49 if (
id == CameraId::cam_left) {
53 if (config.showThresholdImage) {
57 ROS_DEBUG_STREAM(
"Found " << markers.size() <<
" marker(s) in left camera image");
64 ROS_DEBUG_STREAM(
"Found " << markers.size() <<
" marker(s) in right camera image");
74 cv::Mat cameraMatrix(3, 3, CV_32FC1);
75 cv::Mat distorsionCoeff(4, 1, CV_32FC1);
77 cv::Size size(cam_params_left.height, cam_params_left.width);
78 for (
int i=0; i<9; ++i) {
79 cameraMatrix.at<
float>(i%3, i-(i%3)*3) = cam_params_left.K[i];
81 if (cam_params_left.D.size() >= 4) {
82 for (
int i=0; i<4; ++i) {
83 distorsionCoeff.at<
float>(i, 0) = cam_params_left.D[i];
89 size = cv::Size(cam_params_right.height, cam_params_right.width);
90 for (
int i=0; i<9; ++i) {
91 cameraMatrix.at<
float>(i%3, i-(i%3)*3) = cam_params_right.K[i];
93 if (cam_params_right.D.size() >= 4) {
94 for (
int i=0; i<4; ++i) {
95 distorsionCoeff.at<
float>(i, 0) = cam_params_right.D[i];
void setThresholdParams(double param1, double param2)
void detect(const cv::Mat &input, std::vector< Marker > &detectedMarkers, cv::Mat camMatrix=cv::Mat(), cv::Mat distCoeff=cv::Mat(), float markerSizeMeters=-1, bool setYPerperdicular=false)
void setCameraParameters(const sensor_msgs::CameraInfo &cam_params_left, const sensor_msgs::CameraInfo &cam_params_right)
Set the camera parameters of the two cameras.
MarkerDetection()
The default constructor of this class.
aruco::CameraParameters cam_params_left_
aruco::CameraParameters cam_params_right_
void setMinMaxSize(float min=0.03, float max=0.5)
Main class for marker detection.
#define ROS_DEBUG_STREAM(args)
Parameters of the camera.
std::vector< aruco::Marker > detect(const cv::Mat &image, CameraId id, const ArucoMarkerRecognitionConfig &config)
Detects markers in the given image with the camera parameters of the camera with the given id...
#define ROS_ERROR_STREAM(args)
void setThresholdMethod(ThresholdMethods m)