17 #ifndef _ARUCO_MarkerDetector_H
18 #define _ARUCO_MarkerDetector_H
21 #include <opencv2/core/core.hpp>
26 #include <condition_variable>
31 #include <opencv2/imgproc/imgproc.hpp>
82 class CameraParameters;
127 void setDetectionMode(
DetectionMode dm,
float minMarkerSize);
134 enclosedMarker = do_;
154 void setThresholdMethod(
ThresMethod method,
int thresHold = -1,
int wsize = -1,
155 int wsize_range = 0);
171 void save(cv::FileStorage &fs)
const;
172 void load(cv::FileStorage &fs);
174 void toStream(std::ostream &str)
const;
175 void fromStream(std::istream &str);
178 static DetectionMode getDetectionModeFromString(
const std::string &str);
182 static ThresMethod getCornerThresMethodFromString(
const std::string &str);
192 float borderDistThres = 0.015f;
193 int lowResMarkerSize = 20;
201 int minSize_pix = -1;
202 bool enclosedMarker =
false;
203 float error_correction_rate = 0;
204 std::string dictionary =
"ALL_DICTS";
207 int NAttemptsAutoThresFix =
209 int trackingMinDetections = 0;
213 int AdaptiveThresWindowSize = -1, ThresHold = 7, AdaptiveThresWindowSize_range = 0;
215 int markerWarpPixSize = 5;
219 bool autoSize =
false;
239 static void _toStream(
const std::string &strg, std::ostream &str);
240 static void _fromStream(std::string &strg, std::istream &str);
241 template <
typename Type>
242 static bool attemtpRead(
const std::string &name, Type &var, cv::FileStorage &fs)
244 if (fs[name].type() != cv::FileNode::NONE)
265 MarkerDetector(std::string dict_type,
float error_correction_rate = 0);
269 void saveParamsToFile(
const std::string &path)
const;
273 void loadParamsFromFile(
const std::string &path);
302 void setDetectionMode(
DetectionMode dm,
float minMarkerSize = 0);
322 std::vector<aruco::Marker> detect(
const cv::Mat &input);
323 std::vector<aruco::Marker> detect(
const cv::Mat &input,
const CameraParameters &camParams,
324 float markerSizeMeters,
bool setYPerperdicular =
false,
325 bool correctFisheye =
false);
340 void detect(
const cv::Mat &input, std::vector<Marker> &detectedMarkers,
342 bool setYPerperdicular =
false,
bool correctFisheye =
false);
364 void detect(
const cv::Mat &input, std::vector<Marker> &detectedMarkers,
365 cv::Mat camMatrix = cv::Mat(), cv::Mat distCoeff = cv::Mat(),
366 cv::Mat extrinsics = cv::Mat(),
float markerSizeMeters = -1,
367 bool setYPerperdicular =
false,
bool correctFisheye =
false);
371 Params getParameters()
const;
374 Params &getParameters();
390 void setDictionary(std::string dict_type,
float error_correction_rate = 0);
401 void setDictionary(
int dict_type,
float error_correction_rate = 0);
407 cv::Mat getThresholdedImage(uint32_t idx = 0);
424 void setMarkerLabeler(cv::Ptr<MarkerLabeler> detector);
425 cv::Ptr<MarkerLabeler> getMarkerLabeler();
431 std::vector<MarkerCandidate> getCandidates()
const;
433 std::vector<cv::Mat> getImagePyramid();
437 void cornerUpsample(std::vector<std::vector<cv::Point2f> > &corners, cv::Size lowResImageSize);
438 void cornerUpsample(std::vector<Marker> &corners, cv::Size lowResImageSize);
448 bool warp(cv::Mat &in, cv::Mat &out, cv::Size size, std::vector<cv::Point2f> points);
452 void toStream(std::ostream &str)
const;
453 void fromStream(std::istream &str);
455 void setParameters(
const Params ¶ms);