Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLMarkers/src/ICLMarkers/BCHCode.h ** 00010 ** Module : ICLMarkers ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLUtils/CompatMacros.h> 00034 #include <ICLUtils/BasicTypes.h> 00035 #include <ICLUtils/Uncopyable.h> 00036 #include <ICLCore/Img.h> 00037 #include <bitset> 00038 00039 namespace icl{ 00040 namespace markers{ 00041 00043 typedef std::bitset<36> BCHCode; 00044 00046 typedef std::bitset<4096> BCHCodeSubSet; 00047 00049 struct DecodedBCHCode{ 00050 BCHCode origCode; 00051 BCHCode correctedCode; 00052 int id; 00053 int errors; 00054 00056 operator bool() const { return id >= 0; } 00057 00059 bool operator<(const DecodedBCHCode &c){ 00060 return errors < c.errors; 00061 } 00062 }; 00063 00065 struct DecodedBCHCode2D : public DecodedBCHCode{ 00066 DecodedBCHCode2D(){} 00067 DecodedBCHCode2D(const DecodedBCHCode &code):DecodedBCHCode(code),rot(Rot0){} 00068 enum Rotation{ Rot0, Rot90, Rot180, Rot270} rot; 00069 }; 00070 00072 ICLMarkers_API std::ostream &operator<<(std::ostream &s, const DecodedBCHCode2D::Rotation &r); 00073 00075 00076 class ICLMarkers_API BCHCoder : public utils::Uncopyable{ 00077 class Impl; 00078 Impl *impl; 00079 00080 public: 00082 BCHCoder(); 00083 00085 ~BCHCoder(); 00086 00088 static BCHCode encode(int idx); 00089 00091 00098 static core::Img8u createMarkerImage(int idx, int border=2, const utils::Size &resultSize=utils::Size::null); 00099 00101 static BCHCode rotateCode(const BCHCode &in); 00102 00103 00128 DecodedBCHCode decode(const BCHCode &code); 00129 00131 DecodedBCHCode decode(const icl8u data[36]); 00132 00134 DecodedBCHCode decode(const core::Img8u &image, bool useROI=true) throw (utils::ICLException); 00135 00137 00152 DecodedBCHCode2D decode2D(const core::Img8u &image, int maxID=4095, bool useROI=true) throw (utils::ICLException); 00153 00154 }; 00155 } // namespace markers 00156 }