28 #ifndef _ARUCO_MarkerDetector_H 29 #define _ARUCO_MarkerDetector_H 30 #include <opencv2/core/core.hpp> 85 _thresMethod = ADPT_THRES;
86 _thresParam1 = _thresParam2 = 7;
87 _cornerMethod = LINES;
89 _thresParam1_range = 0;
92 _minSize = 0.04;_maxSize = 0.5;_minSize_pix=25;
93 _borderDistThres = 0.005;
118 std::vector<aruco::Marker> detect(
const cv::Mat &input)
throw(cv::Exception);
119 std::vector<aruco::Marker> detect(
const cv::Mat &input,
const CameraParameters &camParams,
float markerSizeMeters ,
bool setYPerperdicular =
false)
throw(cv::Exception);
131 void detect(
const cv::Mat &input, std::vector< Marker > &detectedMarkers,
CameraParameters camParams,
float markerSizeMeters = -1,
132 bool setYPerperdicular =
false)
throw(cv::Exception);
147 void detect(
const cv::Mat &input, std::vector< Marker > &detectedMarkers, cv::Mat camMatrix = cv::Mat(), cv::Mat distCoeff = cv::Mat(),
148 float markerSizeMeters = -1,
bool setYPerperdicular =
false)
throw(cv::Exception);
166 void setDictionary(std::string dict_type,
float error_correction_rate=0)
throw(cv::Exception);
201 _params._thresParam1 = param1;
202 _params._thresParam2 = param2;
221 param1 = _params._thresParam1;
222 param2 = _params._thresParam2;
244 if (min <= 0 || min > 1)
throw cv::Exception(1,
" min parameter out of range",
"MarkerDetector::setMinMaxSize", __FILE__, __LINE__);
245 if (max <= 0 || max > 1)
throw cv::Exception(1,
" max parameter out of range",
"MarkerDetector::setMinMaxSize", __FILE__, __LINE__);
246 if (
min > max)
throw cv::Exception(1,
" min>max",
"MarkerDetector::setMinMaxSize", __FILE__, __LINE__);
247 _params._minSize =
min;
248 _params._maxSize = max;
259 min = _params._minSize;
260 max = _params._maxSize;
278 throw cv::Exception(1,
" invalid canonical image size",
"MarkerDetector::setWarpSize", __FILE__, __LINE__);
279 _params._markerWarpSize = val;
300 void setMarkerLabeler(cv::Ptr<MarkerLabeler> detector)
throw(cv::Exception);
325 void thresHold(
int method,
const cv::Mat &grey, cv::Mat &thresImg,
double param1 = -1,
double param2 = -1) throw(
cv::Exception);
328 void adpt_threshold_multi(const
cv::Mat &grey,
std::vector<
cv::Mat> &out,
double param1 ,
double param1_range ,
double param2,
double param2_range=0 );
333 void detectRectangles(const
cv::Mat &thresImg, vector<
std::vector<
cv::Point2f > > &candidates);
337 const vector<
std::vector<
cv::Point2f > > &getCandidates() {
return _candidates; }
347 bool warp(cv::Mat &in, cv::Mat &out, cv::Size size, std::vector< cv::Point2f > points)
throw(cv::Exception);
354 void refineCandidateLines(
MarkerCandidate &candidate,
const cv::Mat &camMatrix,
const cv::Mat &distCoeff);
360 bool warp_cylinder(cv::Mat &in, cv::Mat &out, cv::Size size,
MarkerCandidate &mc)
throw(cv::Exception);
365 void detectRectangles(vector< cv::Mat > &vimages, vector< MarkerCandidate > &candidates);
377 bool isInto(cv::Mat &contour, std::vector< cv::Point2f > &b);
380 int perimeter(std::vector< cv::Point2f > &a);
383 void interpolate2Dline(
const vector< cv::Point2f > &inPoints, cv::Point3f &outLine);
384 cv::Point2f getCrossPoint(
const cv::Point3f &line1,
const cv::Point3f &line2);
385 void distortPoints(vector< cv::Point2f > in, vector< cv::Point2f > &out,
const cv::Mat &camMatrix,
const cv::Mat &distCoeff);
393 template <
typename T >
void removeElements(vector< T > &vinout,
const vector< bool > &toRemove) {
395 size_t indexValid = 0;
396 for (
size_t i = 0; i < toRemove.size(); i++) {
399 vinout[indexValid] = vinout[i];
403 vinout.resize(indexValid);
407 void drawApproxCurve(cv::Mat &in, std::vector< cv::Point > &approxCurve, cv::Scalar color);
408 void drawContour(cv::Mat &in, std::vector< cv::Point > &contour, cv::Scalar);
409 void drawAllContours(cv::Mat input, std::vector< std::vector< cv::Point > > &contours);
410 void draw(cv::Mat out,
const std::vector< Marker > &markers);
413 void findCornerMaxima(vector< cv::Point2f > &Corners,
const cv::Mat &grey,
int wsize);
417 template <
typename T >
void joinVectors(vector< vector< T > > &vv, vector< T > &v,
bool clearv =
false) {
420 for (
size_t i = 0; i < vv.size(); i++)
421 for (
size_t j = 0; j < vv[i].size(); j++)
422 v.push_back(vv[i][j]);
void setThresholdParams(double param1, double param2)
void getMinMaxSize(float &min, float &max)
ThresholdMethods _thresMethod
void setCornerRefinementMethod(CornerRefinementMethod method, int val=-1)
void getThresholdParams(double ¶m1, double ¶m2) const
void removeElements(vector< T > &vinout, const vector< bool > &toRemove)
cv::Ptr< MarkerLabeler > getMarkerLabeler()
CornerRefinementMethod getCornerRefinementMethod() const
MarkerCandidate & operator=(const MarkerCandidate &M)
void setThresholdParamRange(size_t r1=0, size_t r2=0)
vector< cv::Mat > imagePyramid
MarkerCandidate(const MarkerCandidate &M)
void setMinMaxSize(float min=0.03, float max=0.5)
void setWarpSize(int val)
ThresholdMethods getThresholdMethod() const
This class represents a marker. It is a vector of the fours corners ot the marker.
Main class for marker detection.
const cv::Mat & getThresholdedImage()
Parameters of the camera.
MarkerCandidate(const Marker &M)
int getDesiredSpeed() const
void joinVectors(vector< vector< T > > &vv, vector< T > &v, bool clearv=false)
cv::Ptr< MarkerLabeler > markerIdDetector
vector< cv::Point > contour
CornerRefinementMethod _cornerMethod
void setThresholdMethod(ThresholdMethods m)
void setDesiredSpeed(int val)
vector< std::vector< cv::Point2f > > _candidates