Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
BCHCode.h
Go to the documentation of this file.
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.GPL  **
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 <bitset>
00034 #include <ICLUtils/BasicTypes.h>
00035 #include <ICLUtils/Uncopyable.h>
00036 #include <ICLCore/Img.h>
00037 
00038 namespace icl{
00039   namespace markers{
00040     
00042     typedef std::bitset<36> BCHCode;
00043   
00045     typedef std::bitset<4096> BCHCodeSubSet;
00046     
00048     struct DecodedBCHCode{
00049       BCHCode origCode;      
00050       BCHCode correctedCode; 
00051       int id;                
00052       int errors;            
00053       
00055       operator bool() const { return id >= 0; }
00056   
00058       bool operator<(const DecodedBCHCode &c){
00059         return errors < c.errors;
00060       }
00061     };
00062   
00064     struct DecodedBCHCode2D : public DecodedBCHCode{
00065       DecodedBCHCode2D(){}
00066       DecodedBCHCode2D(const DecodedBCHCode &code):DecodedBCHCode(code),rot(Rot0){}
00067       enum Rotation{ Rot0, Rot90, Rot180, Rot270} rot;
00068     };
00069   
00071     std::ostream &operator<<(std::ostream &s, const DecodedBCHCode2D::Rotation &r);
00072   
00074 
00075     class BCHCoder : public utils::Uncopyable{
00076       class Impl; 
00077       Impl *impl; 
00078       
00079       public:
00081       BCHCoder();
00082   
00084       ~BCHCoder();
00085                   
00087       static BCHCode encode(int idx);
00088     
00090 
00097       static core::Img8u createMarkerImage(int idx, int border=2, const utils::Size &resultSize=utils::Size::null);
00098   
00100       static BCHCode rotateCode(const BCHCode &in);
00101   
00102       
00127       DecodedBCHCode decode(const BCHCode &code);
00128       
00130       DecodedBCHCode decode(const icl8u data[36]);
00131       
00133       DecodedBCHCode decode(const core::Img8u &image, bool useROI=true) throw (utils::ICLException);
00134       
00136 
00151       DecodedBCHCode2D decode2D(const core::Img8u &image, int maxID=4095, bool useROI=true) throw (utils::ICLException);
00152       
00153     };
00154   } // namespace markers
00155 } 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines