Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BarcodeReader_F103
Scanner.h
00001 //------------------------------------------------------------------------ 00002 // Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net> 00003 // 00004 // This file is part of the ZBar Bar Code Reader. 00005 // 00006 // The ZBar Bar Code Reader is free software; you can redistribute it 00007 // and/or modify it under the terms of the GNU Lesser Public License as 00008 // published by the Free Software Foundation; either version 2.1 of 00009 // the License, or (at your option) any later version. 00010 // 00011 // The ZBar Bar Code Reader is distributed in the hope that it will be 00012 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00013 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser Public License 00017 // along with the ZBar Bar Code Reader; if not, write to the Free 00018 // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00019 // Boston, MA 02110-1301 USA 00020 // 00021 // http://sourceforge.net/projects/zbar 00022 //------------------------------------------------------------------------ 00023 #ifndef _ZBAR_SCANNER_H_ 00024 #define _ZBAR_SCANNER_H_ 00025 00026 /// @file 00027 /// Scanner C++ wrapper 00028 00029 #ifndef _ZBAR_H_ 00030 # error "include zbar.h in your application, **not** zbar/Scanner.h" 00031 #endif 00032 00033 #include <stdio.h> 00034 00035 namespace zbar { 00036 00037 /// low-level linear intensity sample stream scanner interface. 00038 /// identifies "bar" edges and measures width between them. 00039 /// optionally passes to bar width Decoder 00040 00041 class Scanner { 00042 public: 00043 00044 /// constructor. 00045 /// @param decoder reference to a Decoder instance which will 00046 /// be passed scan results automatically 00047 Scanner (Decoder& decoder) 00048 { 00049 _scanner = zbar_scanner_create(decoder._decoder); 00050 } 00051 00052 /// constructor. 00053 /// @param decoder pointer to a Decoder instance which will 00054 /// be passed scan results automatically 00055 Scanner (Decoder* decoder = NULL) 00056 { 00057 zbar_decoder_t *zdcode = NULL; 00058 if(decoder) 00059 zdcode = decoder->_decoder; 00060 _scanner = zbar_scanner_create(zdcode); 00061 } 00062 00063 ~Scanner () 00064 { 00065 zbar_scanner_destroy(_scanner); 00066 } 00067 00068 /// clear all scanner state. 00069 /// see zbar_scanner_reset() 00070 void reset () 00071 { 00072 zbar_scanner_reset(_scanner); 00073 } 00074 00075 /// mark start of a new scan pass. 00076 /// see zbar_scanner_new_scan() 00077 zbar_symbol_type_t new_scan () 00078 { 00079 _type = zbar_scanner_new_scan(_scanner); 00080 return(_type); 00081 } 00082 00083 /// flush scanner pipeline. 00084 /// see zbar_scanner_flush() 00085 zbar_symbol_type_t flush () 00086 { 00087 _type = zbar_scanner_flush(_scanner); 00088 return(_type); 00089 } 00090 00091 /// process next sample intensity value. 00092 /// see zbar_scan_y() 00093 zbar_symbol_type_t scan_y (int y) 00094 { 00095 _type = zbar_scan_y(_scanner, y); 00096 return(_type); 00097 } 00098 00099 /// process next sample intensity value. 00100 /// see zbar_scan_y() 00101 Scanner& operator<< (int y) 00102 { 00103 _type = zbar_scan_y(_scanner, y); 00104 return(*this); 00105 } 00106 00107 /// process next sample from RGB (or BGR) triple. 00108 /// see zbar_scan_rgb24() 00109 zbar_symbol_type_t scan_rgb24 (unsigned char *rgb) 00110 { 00111 _type = zbar_scan_rgb24(_scanner, rgb); 00112 return(_type); 00113 } 00114 00115 /// process next sample from RGB (or BGR) triple. 00116 /// see zbar_scan_rgb24() 00117 Scanner& operator<< (unsigned char *rgb) 00118 { 00119 _type = zbar_scan_rgb24(_scanner, rgb); 00120 return(*this); 00121 } 00122 00123 /// retrieve last scanned width. 00124 /// see zbar_scanner_get_width() 00125 unsigned get_width () const 00126 { 00127 return(zbar_scanner_get_width(_scanner)); 00128 } 00129 00130 /// retrieve last scanned color. 00131 /// see zbar_scanner_get_color() 00132 zbar_color_t get_color () const 00133 { 00134 return(zbar_scanner_get_color(_scanner)); 00135 } 00136 00137 /// retrieve last scan result. 00138 zbar_symbol_type_t get_type () const 00139 { 00140 return(_type); 00141 } 00142 00143 /// cast to C scanner 00144 operator zbar_scanner_t* () const 00145 { 00146 return(_scanner); 00147 } 00148 00149 /// retrieve C scanner 00150 const zbar_scanner_t *get_c_scanner () const 00151 { 00152 return(_scanner); 00153 } 00154 00155 private: 00156 zbar_scanner_t *_scanner; 00157 zbar_symbol_type_t _type; 00158 }; 00159 00160 } 00161 00162 #endif
Generated on Tue Jul 12 2022 21:31:48 by
1.7.2