28 #ifndef _ARUCO_MarkerDetector_H 29 #define _ARUCO_MarkerDetector_H 30 #include <opencv2/core/core.hpp> 85 void detect(
const cv::Mat &input, std::vector< Marker > &detectedMarkers, cv::Mat camMatrix = cv::Mat(), cv::Mat distCoeff = cv::Mat(),
86 float markerSizeMeters = -1,
bool setYPerperdicular =
false) throw(
cv::Exception);
98 bool setYPerperdicular = false) throw(
cv::Exception);
120 _thresParam1 = param1;
121 _thresParam2 = param2;
142 void enableLockedCornersMethod(
bool enable);
151 param1 = _thresParam1;
152 param2 = _thresParam2;
175 void setMinMaxSize(
float min = 0.03,
float max = 0.5)
throw(cv::Exception);
201 void setDesiredSpeed(
int val);
210 void setWarpSize(
int val)
throw(cv::Exception);
232 void setMakerDetectorFunction(
int (*markerdetector_func)(
const cv::Mat &in,
int &nRotations)) { markerIdDetector_ptrfunc = markerdetector_func; }
252 void thresHold(
int method,
const cv::Mat &grey, cv::Mat &thresImg,
double param1 = -1,
double param2 = -1)
throw(cv::Exception);
257 void detectRectangles(
const cv::Mat &thresImg, vector< std::vector< cv::Point2f > > &candidates);
261 const vector< std::vector< cv::Point2f > > &
getCandidates() {
return _candidates; }
270 bool warp(cv::Mat &in, cv::Mat &out, cv::Size size, std::vector< cv::Point2f > points)
throw(cv::Exception);
277 void refineCandidateLines(
MarkerCandidate &candidate,
const cv::Mat &camMatrix,
const cv::Mat &distCoeff);
294 static void glGetProjectionMatrix(
CameraParameters &CamMatrix, cv::Size orgImgSize, cv::Size size,
double proj_matrix[16],
double gnear,
double gfar,
295 bool invert =
false)
throw(cv::Exception);
298 bool warp_cylinder(cv::Mat &in, cv::Mat &out, cv::Size size,
MarkerCandidate &mc)
throw(cv::Exception);
303 void detectRectangles(vector< cv::Mat > &vimages, vector< MarkerCandidate > &candidates);
325 int (*markerIdDetector_ptrfunc)(
const cv::Mat &in,
int &nRotations);
329 bool isInto(cv::Mat &contour, std::vector< cv::Point2f > &b);
332 int perimeter(std::vector< cv::Point2f > &a);
345 void findBestCornerInRegion_harris(
const cv::Mat &grey, vector< cv::Point2f > &Corners,
int blockSize);
349 void interpolate2Dline(
const vector< cv::Point2f > &inPoints, cv::Point3f &outLine);
350 cv::Point2f getCrossPoint(
const cv::Point3f &line1,
const cv::Point3f &line2);
351 void distortPoints(vector< cv::Point2f > in, vector< cv::Point2f > &out,
const cv::Mat &camMatrix,
const cv::Mat &distCoeff);
359 template <
typename T >
void removeElements(vector< T > &vinout,
const vector< bool > &toRemove) {
361 size_t indexValid = 0;
362 for (
size_t i = 0; i < toRemove.size(); i++) {
365 vinout[indexValid] = vinout[i];
369 vinout.resize(indexValid);
373 void drawApproxCurve(cv::Mat &in, std::vector< cv::Point > &approxCurve, cv::Scalar color);
374 void drawContour(cv::Mat &in, std::vector< cv::Point > &contour, cv::Scalar);
375 void drawAllContours(cv::Mat input, std::vector< std::vector< cv::Point > > &contours);
376 void draw(cv::Mat out,
const std::vector< Marker > &markers);
379 void findCornerMaxima(vector< cv::Point2f > &Corners,
const cv::Mat &grey,
int wsize);
383 template <
typename T >
void joinVectors(vector< vector< T > > &vv, vector< T > &v,
bool clearv =
false) {
386 for (
size_t i = 0; i < vv.size(); i++)
387 for (
size_t j = 0; j < vv[i].size(); j++)
388 v.push_back(vv[i][j]);
void setThresholdParams(double param1, double param2)
void getMinMaxSize(float &min, float &max)
void pyrDown(unsigned int level)
CornerRefinementMethod _cornerMethod
const vector< std::vector< cv::Point2f > > & getCandidates()
void getThresholdParams(double ¶m1, double ¶m2) const
void removeElements(vector< T > &vinout, const vector< bool > &toRemove)
CornerRefinementMethod getCornerRefinementMethod() const
MarkerCandidate & operator=(const MarkerCandidate &M)
void setThresholdParamRange(size_t r1=0, size_t r2=0)
MarkerCandidate(const MarkerCandidate &M)
ThresholdMethods _thresMethod
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)
void enableErosion(bool enable)
int getDesiredSpeed() const
void joinVectors(vector< vector< T > > &vv, vector< T > &v, bool clearv=false)
void setMakerDetectorFunction(int(*markerdetector_func)(const cv::Mat &in, int &nRotations))
vector< cv::Point > contour
void setThresholdMethod(ThresholdMethods m)
void setCornerRefinementMethod(CornerRefinementMethod method)
vector< std::vector< cv::Point2f > > _candidates