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)
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
00039
00040
00041
00042
00043
00044
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
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
00074
00075
00076 int minimumHammingDistance;
00077
00078
00079
00080
00081
00082
00083
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 }
00105
00106 #endif