Skip to content

Commit

Permalink
finish initial integration of QR Code reader from maemo-barcode project
Browse files Browse the repository at this point in the history
  • Loading branch information
spadix@users.sf.net committed Jul 9, 2009
1 parent 069d9ba commit 672ee19
Show file tree
Hide file tree
Showing 26 changed files with 218 additions and 793 deletions.
5 changes: 4 additions & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Copyright (C) 1999-2009 Timothy B. Terriberry (tterribe@xiph.org)
The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown
<spadix@users.sourceforge.net>
The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry
<tterribe@xiph.org>

You can redistribute this library and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software Foundation;
Expand Down
504 changes: 0 additions & 504 deletions COPYING.LIB

This file was deleted.

1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
current:
* finish initial integration of QR Code reader from maemo-barcode project
* zbar-side updates for QR Code integration
- add linear scanner position interface
- add QR finder position feedback
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EXTRA_DIST =
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = zbar.pc

dist_doc_DATA = COPYING.LIB HACKING INSTALL NEWS README TODO
dist_doc_DATA = COPYING HACKING INSTALL LICENSE NEWS README TODO

include $(srcdir)/include/Makefile.am.inc
include $(srcdir)/zbar/Makefile.am.inc
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ C, C++, Python and Perl as well as GUI widgets for Qt, GTK and PyGTK.
Check the zbar home page for the latest release, mailing lists, etc.
http://zbar.sourceforge.net/

License information can be found in 'COPYING.LIB'.
License information can be found in 'COPYING'.


BUILDING
Expand Down
2 changes: 1 addition & 1 deletion README.windows
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ features a fast, streaming interface with a minimal memory footprint.
Check the ZBar home page for the latest release, mailing lists, etc.
http://zbar.sourceforge.net/

License information can be found in 'COPYING.LIB'.
License information can be found in 'COPYING'.


INSTALLING
Expand Down
Empty file added config/config.rpath
Empty file.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ dnl symbologies

AC_ARG_ENABLE([codes],
[AS_HELP_STRING([--enable-codes=SYMS],
[select symbologies to compile [default=ean,i25,code39,code128]])],
[select symbologies to compile [default=ean,i25,code39,code128,qrcode]])],
[],
[enable_codes="ean,code39,code128,i25"]) dnl pdf417,qr
[enable_codes="ean,code39,code128,i25,qrcode"]) dnl pdf417

AC_DEFUN([ZBAR_CHK_CODE], [
AC_MSG_CHECKING([whether to build $2])
Expand All @@ -102,7 +102,7 @@ ZBAR_CHK_CODE([code128], [Code 128 symbology])
ZBAR_CHK_CODE([code39], [Code 39 symbology])
ZBAR_CHK_CODE([pdf417], [PDF417 symbology])
ZBAR_CHK_CODE([i25], [Interleaved 2 of 5 symbology])
ZBAR_CHK_CODE([qr], [QR Code])
ZBAR_CHK_CODE([qrcode], [QR Code])

dnl libraries

Expand Down
2 changes: 1 addition & 1 deletion include/zbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ typedef enum zbar_symbol_type_e {
ZBAR_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */
ZBAR_CODE39 = 39, /**< Code 39. @since 0.4 */
ZBAR_PDF417 = 57, /**< PDF417. @since 0.6 */
ZBAR_QR = 64, /**< QR Code. @since 0.9 */
ZBAR_QRCODE = 64, /**< QR Code. @since 0.9 */
ZBAR_CODE128 = 128, /**< Code 128 */
ZBAR_SYMBOL = 0x00ff, /**< mask for base symbol type */
ZBAR_ADDON2 = 0x0200, /**< 2-digit add-on flag */
Expand Down
5 changes: 3 additions & 2 deletions zbar.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ FunctionEnd
ZBar Bar Code Reader version ${VERSION}."

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "share\doc\zbar\COPYING.LIB"
!insertmacro MUI_PAGE_LICENSE "share\doc\zbar\LICENSE"

!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_COMPONENTSPAGE_CHECKBITMAP ${NSISDIR}\Contrib\Graphics\Checks\simple-round2.bmp
Expand Down Expand Up @@ -131,7 +131,8 @@ Section "ZBar Core Files (required)" SecCore
File share\doc\zbar\README.windows
File share\doc\zbar\NEWS
File share\doc\zbar\TODO
File share\doc\zbar\COPYING.LIB
File share\doc\zbar\COPYING
File share\doc\zbar\LICENSE

# emit a batch file to add the install directory to the path
FileOpen $0 zbarvars.bat w
Expand Down
3 changes: 2 additions & 1 deletion zbar.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ ldconfig
%{_bindir}/zbarcam
%{_libdir}/libzbar.so.*
%{_datadir}/man/man1/*
%doc %{_docdir}/%{name}-%{version}/COPYING.LIB
%doc %{_docdir}/%{name}-%{version}/COPYING
%doc %{_docdir}/%{name}-%{version}/HACKING
%doc %{_docdir}/%{name}-%{version}/INSTALL
%doc %{_docdir}/%{name}-%{version}/LICENSE
%doc %{_docdir}/%{name}-%{version}/NEWS
%doc %{_docdir}/%{name}-%{version}/README
%doc %{_docdir}/%{name}-%{version}/TODO
Expand Down
14 changes: 7 additions & 7 deletions zbar/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ if ENABLE_PDF417
zbar_libzbar_la_SOURCES += zbar/decoder/pdf417.h zbar/decoder/pdf417.c \
zbar/decoder/pdf417_hash.h
endif
if ENABLE_QR
if ENABLE_QRCODE
zbar_libzbar_la_SOURCES += zbar/decoder/qrcode.h \
zbar/decoder/qr_finder.h zbar/decoder/qr_finder.c \
zbar/decoder/qr/qrdec.c zbar/decoder/qr/qrdectxt.c \
zbar/decoder/qr/rs.h zbar/decoder/qr/rs.c \
zbar/decoder/qr/isaac.h zbar/decoder/qr/isaac.c \
zbar/decoder/qr/bch15_5.h zbar/decoder/qr/bch15_5.c \
zbar/decoder/qr/binarize.h zbar/decoder/qr/binarize.c \
zbar/decoder/qr/util.h zbar/decoder/qr/util.c
zbar/decoder/qrcode/qrdec.c zbar/decoder/qrcode/qrdectxt.c \
zbar/decoder/qrcode/rs.h zbar/decoder/qrcode/rs.c \
zbar/decoder/qrcode/isaac.h zbar/decoder/qrcode/isaac.c \
zbar/decoder/qrcode/bch15_5.h zbar/decoder/qrcode/bch15_5.c \
zbar/decoder/qrcode/binarize.h zbar/decoder/qrcode/binarize.c \
zbar/decoder/qrcode/util.h zbar/decoder/qrcode/util.c
endif

if HAVE_POLL
Expand Down
2 changes: 1 addition & 1 deletion zbar/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int zbar_parse_config (const char *cfgstr,
else if(len < 2)
return(1);
else if(!strncmp(cfgstr, "qrcode", len))
*sym = ZBAR_QR;
*sym = ZBAR_QRCODE;
else if(len < 3)
return(1);
else if(!strncmp(cfgstr, "upca", len))
Expand Down
14 changes: 7 additions & 7 deletions zbar/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ zbar_decoder_t *zbar_decoder_create ()
#ifdef ENABLE_PDF417
dcode->pdf417.config = 1 << ZBAR_CFG_ENABLE;
#endif
#ifdef ENABLE_QR
#ifdef ENABLE_QRCODE
dcode->qrf.config = 1 << ZBAR_CFG_ENABLE;
#endif

Expand Down Expand Up @@ -102,7 +102,7 @@ void zbar_decoder_reset (zbar_decoder_t *dcode)
#ifdef ENABLE_PDF417
pdf417_reset(&dcode->pdf417);
#endif
#ifdef ENABLE_QR
#ifdef ENABLE_QRCODE
qr_finder_reset(&dcode->qrf);
#endif
}
Expand All @@ -128,7 +128,7 @@ void zbar_decoder_new_scan (zbar_decoder_t *dcode)
#ifdef ENABLE_PDF417
pdf417_reset(&dcode->pdf417);
#endif
#ifdef ENABLE_QR
#ifdef ENABLE_QRCODE
qr_finder_reset(&dcode->qrf);
#endif
}
Expand Down Expand Up @@ -203,7 +203,7 @@ zbar_symbol_type_t zbar_decode_width (zbar_decoder_t *dcode,
(sym = _zbar_decode_pdf417(dcode)) > ZBAR_PARTIAL)
dcode->type = sym;
#endif
#ifdef ENABLE_QR
#ifdef ENABLE_QRCODE
if(TEST_CFG(dcode->qrf.config, ZBAR_CFG_ENABLE) &&
(sym = _zbar_find_qr(dcode)) > ZBAR_PARTIAL)
dcode->type = sym;
Expand Down Expand Up @@ -276,8 +276,8 @@ static inline int decoder_set_config_bool (zbar_decoder_t *dcode,
break;
#endif

#ifdef ENABLE_QR
case ZBAR_QR:
#ifdef ENABLE_QRCODE
case ZBAR_QRCODE:
config = &dcode->qrf.config;
break;
#endif
Expand Down Expand Up @@ -360,7 +360,7 @@ int zbar_decoder_set_config (zbar_decoder_t *dcode,
zbar_decoder_set_config(dcode, ZBAR_CODE39, cfg, val);
zbar_decoder_set_config(dcode, ZBAR_CODE128, cfg, val);
zbar_decoder_set_config(dcode, ZBAR_PDF417, cfg, val);
zbar_decoder_set_config(dcode, ZBAR_QR, cfg, val);
zbar_decoder_set_config(dcode, ZBAR_QRCODE, cfg, val);
return(0);
}

Expand Down
4 changes: 2 additions & 2 deletions zbar/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#ifdef ENABLE_PDF417
# include "decoder/pdf417.h"
#endif
#ifdef ENABLE_QR
#ifdef ENABLE_QRCODE
# include "decoder/qr_finder.h"
#endif

Expand Down Expand Up @@ -103,7 +103,7 @@ struct zbar_decoder_s {
#ifdef ENABLE_PDF417
pdf417_decoder_t pdf417; /* PDF417 decode state */
#endif
#ifdef ENABLE_QR
#ifdef ENABLE_QRCODE
qr_finder_t qrf; /* QR Code finder state */
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion zbar/decoder/qr_finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ zbar_symbol_type_t _zbar_find_qr (zbar_decoder_t *dcode)
qrf->line.boffs, qrf->line.pos[0], qrf->line.len,
qrf->line.eoffs);

return(ZBAR_QR);
return(ZBAR_QRCODE);

invalid:
dprintf(2, " [invalid]\n");
Expand Down
52 changes: 52 additions & 0 deletions zbar/decoder/qrcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#if !defined(_qrcode_H)
# define _qrcode_H (1)

#include <zbar.h>

# if defined(__cplusplus)
extern "C" {
# endif
Expand All @@ -18,6 +20,48 @@ typedef struct qr_code_data_entry qr_code_data_entry;
typedef struct qr_code_data qr_code_data;
typedef struct qr_code_data_list qr_code_data_list;

typedef struct qr_finder_line qr_finder_line;

/*The number of bits of subpel precision to store image coordinates in.
This helps when estimating positions in low-resolution images, which may have
a module pitch only a pixel or two wide, making rounding errors matter a
great deal.*/
#define QR_FINDER_SUBPREC (2)

/*A line crossing a finder pattern.
Whether the line is horizontal or vertical is determined by context.
The offsts to various parts of the finder pattern are as follows:
|*****| |*****|*****|*****| |*****|
|*****| |*****|*****|*****| |*****|
^ ^ ^ ^
| | | |
| | | pos[v]+len+eoffs
| | pos[v]+len
| pos[v]
pos[v]-boffs
Here v is 0 for horizontal and 1 for vertical lines.*/
struct qr_finder_line{
/*The location of the upper/left endpoint of the line.
The left/upper edge of the center section is used, since other lines must
cross in this region.*/
qr_point pos;
/*The length of the center section.
This extends to the right/bottom of the center section, since other lines
must cross in this region.*/
int len;
/*The offset to the midpoint of the upper/left section (part of the outside
ring), or 0 if we couldn't identify the edge of the beginning section.
We use the midpoint instead of the edge because it can be located more
reliably.*/
int boffs;
/*The offset to the midpoint of the end section (part of the outside ring),
or 0 if we couldn't identify the edge of the end section.
We use the midpoint instead of the edge because it can be located more
reliably.*/
int eoffs;
};


typedef enum qr_mode{
/*Numeric digits ('0'...'9').*/
QR_MODE_NUM=1,
Expand Down Expand Up @@ -175,6 +219,7 @@ int qr_code_data_list_extract_text(const qr_code_data_list *_qrlist,

qr_reader *qr_reader_alloc(void);
void qr_reader_free(qr_reader *_reader);
void qr_reader_reset(qr_reader *reader);

/*Locate all the QR codes in the given binary image.*/
int qr_reader_locate(qr_reader *_reader,qr_code_data_list *_qrlist,
Expand All @@ -190,6 +235,13 @@ void qr_text_list_free(char **_text,int _ntext);
See http://www.nttdocomo.co.jp/english/service/imode/make/content/barcode/function/application/
for details.*/

int _zbar_qr_found_line(qr_reader *reader,
int direction,
const qr_finder_line *line);
int _zbar_qr_decode(zbar_image_scanner_t *iscn,
qr_reader *reader,
zbar_image_t *img);

# if defined(__cplusplus)
}
# endif
Expand Down
7 changes: 3 additions & 4 deletions zbar/decoder/qrcode/binarize.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ void qr_binarize(unsigned char *_img,int _width,int _height){
/*A simplified adaptive thresholder.
This compares the current pixel value to the mean value of a (large) window
surrounding it.*/
void qr_binarize(unsigned char *_img,int _width,int _height){
unsigned char *qr_binarize(const unsigned char *_img,int _width,int _height){
unsigned char *mask = NULL;
if(_width>0&&_height>0){
unsigned char *mask;
unsigned *col_sums;
int logwindw;
int logwindh;
Expand Down Expand Up @@ -587,8 +587,6 @@ void qr_binarize(unsigned char *_img,int _width,int _height){
}
}
free(col_sums);
memcpy(_img,mask,_width*_height*sizeof(*_img));
free(mask);
}
#if defined(QR_DEBUG)
{
Expand All @@ -598,6 +596,7 @@ void qr_binarize(unsigned char *_img,int _width,int _height){
fclose(fout);
}
#endif
return(mask);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion zbar/decoder/qrcode/binarize.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ void qr_image_cross_masking_median_filter(unsigned char *_img,
void qr_wiener_filter(unsigned char *_img,int _width,int _height);

/*Binarizes a grayscale image.*/
void qr_binarize(unsigned char *_img,int _width,int _height);
unsigned char *qr_binarize(const unsigned char *_img,int _width,int _height);

#endif
Loading

0 comments on commit 672ee19

Please sign in to comment.