diff options
author | shamikam | 2017-01-16 02:56:17 +0530 |
---|---|---|
committer | shamikam | 2017-01-16 02:56:17 +0530 |
commit | a6df67e8bcd5159cde27556f4f6a315f8dc2215f (patch) | |
tree | e806e966b06a53388fb300d89534354b222c2cad /thirdparty1/linux/include/opencv2/aruco/dictionary.hpp | |
download | FOSSEE_Image_Processing_Toolbox-master.tar.gz FOSSEE_Image_Processing_Toolbox-master.tar.bz2 FOSSEE_Image_Processing_Toolbox-master.zip |
Diffstat (limited to 'thirdparty1/linux/include/opencv2/aruco/dictionary.hpp')
-rw-r--r-- | thirdparty1/linux/include/opencv2/aruco/dictionary.hpp | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/thirdparty1/linux/include/opencv2/aruco/dictionary.hpp b/thirdparty1/linux/include/opencv2/aruco/dictionary.hpp new file mode 100644 index 0000000..b94ee25 --- /dev/null +++ b/thirdparty1/linux/include/opencv2/aruco/dictionary.hpp @@ -0,0 +1,205 @@ +/* +By downloading, copying, installing or using the software you agree to this +license. If you do not agree to this license, do not download, install, +copy or use the software. + + License Agreement + For Open Source Computer Vision Library + (3-clause BSD License) + +Copyright (C) 2013, OpenCV Foundation, all rights reserved. +Third party copyrights are property of their respective owners. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the names of the copyright holders nor the names of the contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are +disclaimed. In no event shall copyright holders or contributors be liable for +any direct, indirect, incidental, special, exemplary, or consequential damages +(including, but not limited to, procurement of substitute goods or services; +loss of use, data, or profits; or business interruption) however caused +and on any theory of liability, whether in contract, strict liability, +or tort (including negligence or otherwise) arising in any way out of +the use of this software, even if advised of the possibility of such damage. +*/ + +#ifndef __OPENCV_DICTIONARY_HPP__ +#define __OPENCV_DICTIONARY_HPP__ + +#include <opencv2/core.hpp> + +namespace cv { +namespace aruco { + +//! @addtogroup aruco +//! @{ + + +/** + * @brief Dictionary/Set of markers. It contains the inner codification + * + * bytesList contains the marker codewords where + * - bytesList.rows is the dictionary size + * - each marker is encoded using `nbytes = ceil(markerSize*markerSize/8.)` + * - each row contains all 4 rotations of the marker, so its length is `4*nbytes` + * + * `bytesList.ptr(i)[k*nbytes + j]` is then the j-th byte of i-th marker, in its k-th rotation. + */ +class CV_EXPORTS_W Dictionary { + + public: + CV_PROP Mat bytesList; // marker code information + CV_PROP int markerSize; // number of bits per dimension + CV_PROP int maxCorrectionBits; // maximum number of bits that can be corrected + + + /** + */ + Dictionary(const Mat &_bytesList = Mat(), int _markerSize = 0, int _maxcorr = 0); + + + /** + Dictionary(const Dictionary &_dictionary); + */ + + + /** + */ + Dictionary(const Ptr<Dictionary> &_dictionary); + + + /** + * @see generateCustomDictionary + */ + CV_WRAP_AS(create) static Ptr<Dictionary> create(int nMarkers, int markerSize); + + + /** + * @see generateCustomDictionary + */ + CV_WRAP_AS(create_from) static Ptr<Dictionary> create(int nMarkers, int markerSize, + const Ptr<Dictionary> &baseDictionary); + + /** + * @see getPredefinedDictionary + */ + CV_WRAP static Ptr<Dictionary> get(int dict); + + /** + * @brief Given a matrix of bits. Returns whether if marker is identified or not. + * It returns by reference the correct id (if any) and the correct rotation + */ + bool identify(const Mat &onlyBits, int &idx, int &rotation, double maxCorrectionRate) const; + + /** + * @brief Returns the distance of the input bits to the specific id. If allRotations is true, + * the four posible bits rotation are considered + */ + int getDistanceToId(InputArray bits, int id, bool allRotations = true) const; + + + /** + * @brief Draw a canonical marker image + */ + CV_WRAP void drawMarker(int id, int sidePixels, OutputArray _img, int borderBits = 1) const; + + + /** + * @brief Transform matrix of bits to list of bytes in the 4 rotations + */ + static Mat getByteListFromBits(const Mat &bits); + + + /** + * @brief Transform list of bytes to matrix of bits + */ + static Mat getBitsFromByteList(const Mat &byteList, int markerSize); +}; + + + + +/** + * @brief Predefined markers dictionaries/sets + * Each dictionary indicates the number of bits and the number of markers contained + * - DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum + distance + */ +enum CV_EXPORTS_W_SIMPLE PREDEFINED_DICTIONARY_NAME { + DICT_4X4_50 = 0, + DICT_4X4_100, + DICT_4X4_250, + DICT_4X4_1000, + DICT_5X5_50, + DICT_5X5_100, + DICT_5X5_250, + DICT_5X5_1000, + DICT_6X6_50, + DICT_6X6_100, + DICT_6X6_250, + DICT_6X6_1000, + DICT_7X7_50, + DICT_7X7_100, + DICT_7X7_250, + DICT_7X7_1000, + DICT_ARUCO_ORIGINAL +}; + + +/** + * @brief Returns one of the predefined dictionaries defined in PREDEFINED_DICTIONARY_NAME + */ +CV_EXPORTS Ptr<Dictionary> getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name); + + +/** + * @brief Returns one of the predefined dictionaries referenced by DICT_*. + */ +CV_EXPORTS_W Ptr<Dictionary> getPredefinedDictionary(int dict); + + +/** + * @see generateCustomDictionary + */ +CV_EXPORTS_AS(custom_dictionary) Ptr<Dictionary> generateCustomDictionary( + int nMarkers, + int markerSize); + + +/** + * @brief Generates a new customizable marker dictionary + * + * @param nMarkers number of markers in the dictionary + * @param markerSize number of bits per dimension of each markers + * @param baseDictionary Include the markers in this dictionary at the beginning (optional) + * + * This function creates a new dictionary composed by nMarkers markers and each markers composed + * by markerSize x markerSize bits. If baseDictionary is provided, its markers are directly + * included and the rest are generated based on them. If the size of baseDictionary is higher + * than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added. + */ +CV_EXPORTS_AS(custom_dictionary_from) Ptr<Dictionary> generateCustomDictionary( + int nMarkers, + int markerSize, + const Ptr<Dictionary> &baseDictionary); + + + +//! @} +} +} + +#endif |