diff --git a/detect.cpp b/detect.cpp index 4c76a49..61eab05 100644 --- a/detect.cpp +++ b/detect.cpp @@ -1,3 +1,18 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Detection core implementation file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #include "detect.h" #include "tools.h" @@ -8,10 +23,12 @@ using namespace ocv_ar; #pragma mark public methods Detect::Detect(IdentificatorType identType, float markerSizeM, FlipMode flip) { + // use marker size default if (markerSizeM <= 0.0f) markerSizeM = OCV_AR_CONF_DEFAULT_MARKER_SIZE_REAL; printf("ocv_ar::Detect - projection flip mode: %d\n", (int)flip); + // set defaults markerScale = markerSizeM; flipProj = flip; prepared = false; @@ -30,6 +47,8 @@ Detect::Detect(IdentificatorType identType, float markerSizeM, FlipMode flip) { downsampleSizeW = downsampleSizeH = 0; ident = NULL; + + // set identificator setIdentificatorType(identType); #if !defined(OCV_AR_CONF_DOWNSAMPLE) && defined(OCV_AR_CONF_RESIZE_W) && defined(OCV_AR_CONF_RESIZE_H) @@ -39,6 +58,8 @@ Detect::Detect(IdentificatorType identType, float markerSizeM, FlipMode flip) { } Detect::~Detect() { + // delete allocated memory + if (inFrameOrigGray) delete inFrameOrigGray; if (inFrame) delete inFrame; if (procFrame) delete procFrame; @@ -51,6 +72,7 @@ void Detect::setIdentificatorType(IdentificatorType identType) { printf("ocv_ar::Detect - loading identificator type %d\n", identType); + // create an identificator object switch (identType) { case IDENT_TYPE_CODE_7BIT: ident = new Identificator7BitCode(); @@ -67,6 +89,7 @@ void Detect::setIdentificatorType(IdentificatorType identType) { break; } + // set normalized marker coordinates for 2D and 3D space normMarkerCoord2D.clear(); normMarkerCoord3D.clear(); @@ -150,6 +173,7 @@ void Detect::setCamIntrinsics(const cv::Mat &cam, const cv::Mat &dist) { float *Detect::getProjMat(float viewW, float viewH) { assert(!camMat.empty() && viewW > 0.0f && viewH > 0.0f && prepared); + // re-calculate the projection matrix if necessary if (viewW != projMatUsedSize.width || viewH != projMatUsedSize.height) { calcProjMat(viewW, viewH); } @@ -175,6 +199,7 @@ void Detect::setFrameOutputLevel(FrameProcLevel level) { delete outFrame; } + // allocate memory for the output frame outFrame = new cv::Mat(outH, outW, CV_8UC1); printf("ocv_ar::Detect - set output frame level: %d (output frame size %dx%d)", level, outW, outH); @@ -189,6 +214,8 @@ void Detect::setInputFrame(cv::Mat *frame) { } void Detect::processFrame() { + // defines the whole marker detection pipeline: + preprocess(); performThreshold(); findContours(); @@ -206,6 +233,8 @@ cv::Mat *Detect::getOutputFrame() const { #pragma mark private methods void Detect::preprocess() { + // downscale the image + #ifdef OCV_AR_CONF_DOWNSAMPLE for (int i = 0; i < OCV_AR_CONF_DOWNSAMPLE; i++) { cv::pyrDown(*inFrameOrigGray, *inFrame); @@ -222,6 +251,8 @@ void Detect::preprocess() { } void Detect::performThreshold() { + // perform thresholding + cv::adaptiveThreshold(*inFrame, *procFrame, 255, @@ -249,6 +280,7 @@ void Detect::findContours() { it != allContours.end(); ++it) { + // add this contour to our vector in case it could form a marker if (it->size() >= OCV_AR_CONF_MIN_CONTOUR_PTS) { curContours.push_back(*it); } @@ -265,10 +297,12 @@ void Detect::findContours() { void Detect::findMarkerCandidates() { const float minContourLengthAllowed = OCV_AR_CONF_MIN_CONTOUR_LENGTH * OCV_AR_CONF_MIN_CONTOUR_LENGTH; + // tabula rasa for the new frame foundMarkers.clear(); possibleMarkers.clear(); PointVec approxCurve; + // analyze each contour for (ContourVec::const_iterator it = curContours.begin(); it != curContours.end(); ++it) @@ -302,6 +336,8 @@ void Detect::findMarkerCandidates() { // printf("ocv_ar::Detect - Num. marker candidates: %lu\n", possibleMarkers.size()); + // duplicate markers are possible, especially when double edges are detected + // filter them out discardDuplicateMarkers(possibleMarkers); // printf("ocv_ar::Detect - Num. marker candidates without duplicates: %lu\n", possibleMarkers.size()); @@ -376,16 +412,23 @@ void Detect::identifyMarkers() { } void Detect::estimatePositions() { - for (vector::iterator it = foundMarkers.begin(); it != foundMarkers.end(); ++it) { + // estimate the 3D pose of each found marker + for (vector::iterator it = foundMarkers.begin(); + it != foundMarkers.end(); + ++it) + { Marker *marker = *it; - cv::Mat rVec; - cv::Mat tVec; + // find marker pose from 3D-2D point correspondences between + // and 2D points in getPoints()> + cv::Mat rVec; // pose rotation vector + cv::Mat tVec; // pose translation vector cv::solvePnP(normMarkerCoord3D, marker->getPoints(), camMat, distCoeff, rVec, tVec, false); + // generate an OpenGL model-view matrix from the rotation and translation vectors marker->updatePoseMat(rVec, tVec); } } @@ -554,6 +597,6 @@ void Detect::calcProjMat(float viewW, float viewH) { projMat[8] = -projMat[8]; projMat[12] = -projMat[12]; } - + /* END modified code from ArUco lib */ } \ No newline at end of file diff --git a/detect.h b/detect.h index 37a8110..3b6c5df 100644 --- a/detect.h +++ b/detect.h @@ -6,6 +6,10 @@ * Author: Markus Konrad , June 2014. * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * * See LICENSE for license. */ diff --git a/ident.cpp b/ident.cpp index 6b6bece..f5ed930 100644 --- a/ident.cpp +++ b/ident.cpp @@ -1,3 +1,14 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker identification base class -- implementation file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * See LICENSE for license. + */ + #include "ident.h" using namespace ocv_ar; diff --git a/ident.h b/ident.h index ab2d62b..3600feb 100644 --- a/ident.h +++ b/ident.h @@ -1,3 +1,14 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker identification base class -- header file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * See LICENSE for license. + */ + #ifndef OCV_AR_IDENT_H #define OCV_AR_IDENT_H @@ -8,26 +19,51 @@ namespace ocv_ar { +/** + * Abstract base class for all identificators providing common methods and a uniform + * interface. + */ class IdentificatorBase { public: + /** + * Base constructor to set the identificator type and the required marker size + * in pixels. + */ IdentificatorBase(IdentificatorType t, int markerSize) : reqMarkerSize(markerSize), type(t) {}; + /** + * Empty virtual deconstructor. + */ virtual ~IdentificatorBase() {}; + /** + * Abstract method to read a marker code from the image region and save + * possible results in . + * Returns true if the code could be read, otherwise false. + */ virtual bool readMarkerCode(const cv::Mat &area, Marker &marker) = 0; - virtual int getRequiredMarkerSize() const { return reqMarkerSize; } + /** + * Returns the required marker size. + */ + int getRequiredMarkerSize() const { return reqMarkerSize; } + /** + * Returns the idenficator type. + */ IdentificatorType getType() { return type; } protected: + /** + * Helper function to set an and a valid rotation to a . + */ void setFoundPropertiesForMarker(Marker &marker, int id, int rot); - IdentificatorType type; - int reqMarkerSize; + IdentificatorType type; // identificator type + int reqMarkerSize; // required marker size }; } diff --git a/ident_7bit.cpp b/ident_7bit.cpp index 1b27578..e9688c3 100644 --- a/ident_7bit.cpp +++ b/ident_7bit.cpp @@ -1,3 +1,18 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker identification for ArUco style 7x7 markers -- implementation file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #include "ident_7bit.h" using namespace ocv_ar; diff --git a/ident_7bit.h b/ident_7bit.h index c070238..b851309 100644 --- a/ident_7bit.h +++ b/ident_7bit.h @@ -1,3 +1,20 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker identification for ArUco style 7x7 markers -- header file. + * Note: Although the markers use 7x7 binary fields, only the inner 5x5 fields + * carry information (i.e. the marker code). + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #ifndef OCV_AR_IDENT_7BIT_H #define OCV_AR_IDENT_7BIT_H @@ -9,22 +26,44 @@ namespace ocv_ar { +/** + * Marker idenfication for ArUco style 7x7 markers. + * A possible marker square can be analyzed and - if it is a valid marker - its ID + * can be calculated from the code embedded in the inner 5x5 binary marker fields. + */ class Identificator7BitCode : public IdentificatorBase { public: + /** + * Constructor. Create a new idenficiator of type IDENT_TYPE_CODE_7BIT. + */ Identificator7BitCode() : IdentificatorBase(IDENT_TYPE_CODE_7BIT, 7 * OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD), markerCellSize(OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD), minSetMarkerPixels(OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD * OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD / 2) {}; + /** + * Try to read the marker code from the quadratic image part by trying out all + * four possbile rotations of the image. If an ID could be read, set the found ID and + * valid rotation in and return true, otherwise return false. + */ virtual bool readMarkerCode(const cv::Mat &area, Marker &marker); private: + /** + * Helper function to check if a marker code is valid when the extracted marker code + * matrix is read in direction . + */ bool checkMarkerCode(const cv::Mat &m, int dir) const; + + /** + * Helper function to read the marker code from the extracted marker code + * matrix by using direction . + */ int markerCodeToId(const cv::Mat &m, int dir) const; - int markerCellSize; - int minSetMarkerPixels; + int markerCellSize; // cell size of each marker field in pixels + int minSetMarkerPixels; // minimum of white marker pixels that must be set if a field should be regarded "1" }; } diff --git a/ident_templ.cpp b/ident_templ.cpp index 8aff741..17fa3c7 100644 --- a/ident_templ.cpp +++ b/ident_templ.cpp @@ -1,3 +1,15 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker identification via simple template matching of binary + * images -- implementation file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * See LICENSE for license. + */ + #include "ident_templ.h" #include "tools.h" @@ -11,9 +23,12 @@ IdentificatorTemplMatch::IdentificatorTemplMatch() : borderSize(OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD), minSetMarkerPixels(OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD * OCV_AR_CONF_MARKER_CODE_PX_PER_FIELD / 2) { + // calculate defaults templSize = reqMarkerSize - 2 * borderSize; templSizeSq = templSize * templSize; - printf("ocv_ar::IdentificatorTemplMatch - req. marker size: %d, templ. size: %d\n", reqMarkerSize, templSize); + + printf("ocv_ar::IdentificatorTemplMatch - req. marker size: %d, templ. size: %d\n", + reqMarkerSize, templSize); } IdentificatorTemplMatch::~IdentificatorTemplMatch() { @@ -147,8 +162,10 @@ bool IdentificatorTemplMatch::checkTemplateRotations(const cv::Mat &marker, cons cv::Mat errorMat(marker.rows, marker.cols, CV_8UC1); for (int r = 0; r < 4; r++) { // check all four rotations + // do a bitwise or so that we get "1"s where the two images do not fit cv::bitwise_xor(marker, templRotations[r], errorMat); + // could the pixels that do not fit float errRate = (float)cv::countNonZero(errorMat) / (float)templSizeSq; printf("ocv_ar::IdentificatorTemplMatch - rotation %d, error rate %f\n", r, errRate); diff --git a/ident_templ.h b/ident_templ.h index 5a61f04..bbbd38c 100644 --- a/ident_templ.h +++ b/ident_templ.h @@ -1,3 +1,15 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker identification via simple template matching of binary + * images -- header file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * See LICENSE for license. + */ + #ifndef OCV_AR_IDENT_TEMPL_H #define OCV_AR_IDENT_TEMPL_H @@ -9,26 +21,65 @@ namespace ocv_ar { +/** + * Marker idenfication via simple template matching of binary images. + * The binarized image of a possible marker square is matched up with images + * in a "template library", which contains all valid binary marker images. + * Note that each marker image requires to have a surrounding border around that + * has a width of 1/8th of the overall image size. + */ class IdentificatorTemplMatch : public IdentificatorBase { public: + /** + * Constructor. Create a new idenficiator of type IDENT_TYPE_TEMPL_MATCH. + */ IdentificatorTemplMatch(); + /** + * Deconstructor. Will free memory for the images in . + */ virtual ~IdentificatorTemplMatch(); + /** + * Check if may contain be a valid marker (check its black border). Then + * match the binary image inside the borders against all images in by + * performing a binary xor operation for all possible rotations and choosing the + * best matching rotation beneath a certain threshold OCV_AR_CONF_TEMPL_MATCH_MAX_ERROR_RATE. + * If a matching template could be read, set the found ID and + * valid rotation in and return true, otherwise return false. + */ virtual bool readMarkerCode(const cv::Mat &area, Marker &marker); + /** + * Add a template image (associated with ID ) to the template library. + * If is true, a border consuming 1/8th of the image width on each side + * will be cut away. If is true, the image will be thresholded using Otsu. + */ void addTemplateImg(int id, const cv::Mat &img, bool stripBorder = true, bool binarize = false); private: + /** + * Helper function to match the image against the templates with 4 possible rotations + * in . Return true if the best result underneath a certain threshold + * OCV_AR_CONF_TEMPL_MATCH_MAX_ERROR_RATE could be found and will set the correct rotation in + * . Otherwise returns false. + */ bool checkTemplateRotations(const cv::Mat &marker, const cv::Mat *templRotations, int *validRot); + + /** + * Check if the one border in , identified by direction (0 = horizontal, 1 = vertical) + * and an offset for the second coordinate, is valid (all black). Returns true if this is + * the case, otherwise false. + */ bool checkBorder(const cv::Mat &img, int dir, int off); - int borderSize; - int templSize; - int templSizeSq; - int minSetMarkerPixels; - TemplateMap templates; + int borderSize; // border size in pixels + int templSize; // template size in pixels + int templSizeSq; // squared template size in pixels + int minSetMarkerPixels; // minimum of white marker pixels that must be set if a field should be regarded "1" + TemplateMap templates; // template library that maps an int id to an array cv::Mat[4] with all 4 rotations + // of a template image }; } diff --git a/marker.cpp b/marker.cpp index 0b528a5..1e750cd 100644 --- a/marker.cpp +++ b/marker.cpp @@ -1,3 +1,18 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker class to describe single found markers in an image -- implementation file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #include "marker.h" using namespace ocv_ar; @@ -5,10 +20,12 @@ using namespace ocv_ar; #pragma mark public methods Marker::Marker(PointVec &pts) { + // convert points to cv::Point2f and add to the vector for (int i = 0; i < 4; i++) { points.push_back(cv::Point2f(pts[i].x, pts[i].y)); } + // common init init(); } @@ -16,6 +33,7 @@ Marker::Marker(PointVec &pts) { Marker::Marker(Point2fVec &pts) { points.assign(pts.begin(), pts.begin() + 4); + // common init init(); } @@ -77,7 +95,11 @@ void Marker::sortPoints() { } void Marker::calcShapeProperties() { + // centroid is the mean of all points centroid = 0.25f * (points[0] + points[1] + points[2] + points[3]); + + // perimeter radius is the maximum distance between the centroid + // and a corner point float maxDist = numeric_limits::min(); for (Point2fVec::iterator it = points.begin(); it != points.end(); @@ -93,6 +115,7 @@ void Marker::calcShapeProperties() { #pragma mark private methods void Marker::init() { + // set defaults id = -1; rVec.create(3, 1, CV_32F); diff --git a/marker.h b/marker.h index 500ac88..717854a 100644 --- a/marker.h +++ b/marker.h @@ -1,3 +1,18 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Marker class to describe single found markers in an image -- header file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #ifndef OCV_AR_MARKER_H #define OCV_AR_MARKER_H @@ -13,49 +28,114 @@ using namespace std; namespace ocv_ar { +/** + * Marker class that describes the properties of a possible or valid marker in + * an image. + */ class Marker { public: + /** + * Constructor to create a marker with the corner points , submitted as + * PointVec. + */ Marker(PointVec &pts); + + /** + * Constructor to create a marker with the corner points , submitted as + * Point2fVec. + */ Marker(Point2fVec &pts); + /** + * Set the marker ID to . + */ void setId(int newId) { id = newId; }; + + /** + * Return the marker ID. + */ int getId() const { return id; }; + /** + * Return the corner points of this marker. + */ Point2fVec getPoints() const { return points; } + + /** + * Add a point

to the corner points. + */ void addPoint(cv::Point2f p) { points.push_back(p); } + + /** + * Clear the corner points. + */ void clearPoints() { points.clear(); } + + /** + * Rotate the corner points in the vector times. + */ void rotatePoints(int rot); + /** + * Return the controid calculated from the corner points. + */ cv::Point2f getCentroid() const { return centroid; } + + /** + * Return the perimeter radius calculated from the corner points. + */ float getPerimeterRadius() const { return perimeterRad; } + /** + * Return the 3D pose rotation vector. + */ const cv::Mat &getRVec() const { return rVec; }; + + /** + * Return the 3D pose translation vector. + */ const cv::Mat &getTVec() const { return tVec; }; + /** + * Update the 3D pose by rotation vector and translation vector . + */ void updatePoseMat(const cv::Mat &r, const cv::Mat &t); -// const glm::mat4 &getPoseMat() const { return poseMat; }; - + /** + * Return the 4x4 OpenGL 3D pose model-view matrix as pointer to + * the internal float[16]. + */ const float *getPoseMatPtr() const { return poseMat; }; + /** + * Sort the points in anti-clockwise order. + */ void sortPoints(); + + /** + * Calculate the shape properties from the corner points like centroid + * and perimeter radius. + */ void calcShapeProperties(); private: + /** + * Common initialize method for the marker class. + */ void init(); - int id; - Point2fVec points; + int id; // marker ID + + Point2fVec points; // corner points - cv::Point2f centroid; - float perimeterRad; + cv::Point2f centroid; // centroid formed by the corner points + float perimeterRad; // perimenter radius formed by the corner points - cv::Mat rVec; - cv::Mat tVec; + cv::Mat rVec; // 3D pose rotation vector + cv::Mat tVec; // 3D pose translation vector - float poseMat[16]; // 4x4 matrix with model-view-transformation -// glm::mat4 poseMat; // 4x4 matrix with model-view-transformation + float poseMat[16]; // OpenGL 4x4 matrix with model-view-transformation }; } diff --git a/ocv_ar.h b/ocv_ar.h index 0c09db8..8cb68f8 100644 --- a/ocv_ar.h +++ b/ocv_ar.h @@ -6,6 +6,10 @@ * Author: Markus Konrad , June 2014. * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ * + * This project contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * * See LICENSE for license. */ diff --git a/tools.cpp b/tools.cpp index 668501e..ef2c162 100644 --- a/tools.cpp +++ b/tools.cpp @@ -1,3 +1,18 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Helper function class "Tools" -- implementation file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #include "tools.h" using namespace ocv_ar; diff --git a/tools.h b/tools.h index 45bf303..8094942 100644 --- a/tools.h +++ b/tools.h @@ -1,3 +1,18 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Helper function class "Tools" -- header file. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * This file contains code and inspiration from ArUco library developed at the + * Ava group of the Univeristy of Cordoba (Spain). + * See http://sourceforge.net/projects/aruco/ + * + * See LICENSE for license. + */ + #ifndef OCV_AR_TOOLS_H #define OCV_AR_TOOLS_H @@ -5,15 +20,27 @@ namespace ocv_ar { +/** + * Misc. helper functions. + */ class Tools { public: + /** + * Return the distance between and . + */ static float distSquared(cv::Point2f p1, cv::Point2f p2); - static void matRot90CW(cv::Mat &m); // fast clock-wise rotation of by 90° + /** + * Fast clock-wise rotation of by 90° + */ + static void matRot90CW(cv::Mat &m); + +/* BEGIN code from ArUco lib */ static float norm( float a, float b, float c ); static float dot( float a1, float a2, float a3, float b1, float b2, float b3 ); static int arParamDecompMat( float source[3][4], float cpara[3][4], float trans[3][4] ); +/* END code from ArUco lib */ }; } diff --git a/types.h b/types.h index 360d169..56985ac 100644 --- a/types.h +++ b/types.h @@ -1,3 +1,14 @@ +/** + * ocv_ar - OpenCV based Augmented Reality library + * + * Common type definitions. + * + * Author: Markus Konrad , June 2014. + * INKA Research Group, HTW Berlin - http://inka.htw-berlin.de/ + * + * See LICENSE for license. + */ + #ifndef OCV_AR_TYPES_H #define OCV_AR_TYPES_H @@ -7,12 +18,18 @@ #include namespace ocv_ar { + /** + * Flip mode for projection matrix + */ typedef enum _FlipMode { FLIP_NONE, FLIP_H, // horizontal flip FLIP_V // vertical flip } FlipMode; + /** + * Frame processing levels in the marker detection pipeline + */ typedef enum _FrameProcLevel { PROC_LEVEL_DEFAULT = -1, PROC_LEVEL_PREPROC, @@ -22,6 +39,9 @@ namespace ocv_ar { PROC_LEVEL_DETECTED_MARKERS } FrameProcLevel; + /** + * Identificator types + */ typedef enum _IdentificatorType { IDENT_TYPE_NONE = -1, IDENT_TYPE_CODE_7BIT, @@ -29,11 +49,21 @@ namespace ocv_ar { // CODE_8BIT, } IdentificatorType; + /** + * Different point vectors + */ typedef std::vector PointVec; typedef std::vector Point2fVec; typedef std::vector Point3fVec; + + /** + * A vector of a point vector + */ typedef std::vector ContourVec; + /** + * Template map + */ typedef std::map TemplateMap; // maps id to array of 4 rotated templates typedef std::pair TemplateMapPair; }