TagFamily.h
Go to the documentation of this file.
00001 #ifndef TAGFAMILY_H
00002 #define TAGFAMILY_H
00003 
00004 #include <climits>
00005 #include <cmath>
00006 #include <stdio.h>
00007 #include <vector>
00008 #include <map>
00009 
00010 #include "AprilTags/TagDetection.h"
00011 using namespace std;
00012 
00013 namespace AprilTags {
00014 
00015 class TagCodes {
00016 public:
00017   int bits;
00018   int minHammingDistance;
00019   std::vector<unsigned long long> codes;
00020 public:
00021  TagCodes(int bits, int minHammingDistance,
00022           const unsigned long long* codesA, int num)
00023    : bits(bits), minHammingDistance(minHammingDistance),
00024     codes(codesA, codesA+num) // created vector for all entries of codesA
00025       {}
00026 };
00027 
00029 class TagFamily {
00030 public:
00032   TagFamily(const TagCodes& tagCodes);
00033 
00034   void setErrorRecoveryBits(int b);
00035 
00036   void setErrorRecoveryFraction(float v);
00037 
00038   /* if the bits in w were arranged in a d*d grid and that grid was
00039    * rotated, what would the new bits in w be?
00040    * The bits are organized like this (for d = 3):
00041    *
00042    *  8 7 6       2 5 8      0 1 2
00043    *  5 4 3  ==>  1 4 7 ==>  3 4 5    (rotate90 applied twice)
00044    *  2 1 0       0 3 6      6 7 8
00045    */
00046   static unsigned long long rotate90(unsigned long long w, int d);
00047 
00049   static int hammingDistance(unsigned long long a, unsigned long long b);
00050 
00052   static unsigned char popCountReal(unsigned long long w);
00053 
00054   static int popCount(unsigned long long w);
00055 
00057   /*  The corresponding fields of TagDetection will be filled in. */
00058   void decode(TagDetection& det, unsigned long long rCode) const;
00059 
00061   void printHammingDistances() const;
00062 
00064   int blackBorder;
00065 
00067   int bits;
00068 
00070   int dimension;
00071 
00073   /*  Accounting for rotational ambiguity? The code can recover
00074    *  (minHammingDistance-1)/2 bit errors.
00075    */
00076   int minimumHammingDistance;
00077 
00078   /* The error recovery value determines our position on the ROC
00079    * curve. We will report codes that are within errorRecoveryBits
00080    * of a valid code. Small values mean greater rejection of bogus
00081    * tags (but false negatives). Large values mean aggressive
00082    * reporting of bad tags (but with a corresponding increase in
00083    * false positives).
00084    */
00085   int errorRecoveryBits;
00086 
00088   std::vector<unsigned long long> codes;
00089 
00090   static const int  popCountTableShift = 12;
00091   static const unsigned int popCountTableSize = 1 << popCountTableShift;
00092   static unsigned char popCountTable[popCountTableSize];
00093 
00095   static class TableInitializer {
00096   public:
00097     TableInitializer() {
00098       for (unsigned int i = 0; i < TagFamily::popCountTableSize; i++)
00099         TagFamily::popCountTable[i] = TagFamily::popCountReal(i);
00100     }
00101   } initializer;
00102 };
00103 
00104 } // namespace
00105 
00106 #endif


apriltags
Author(s): Mitchell Wills
autogenerated on Thu Aug 27 2015 12:23:28