grcode

package module
v0.0.0-...-46fb13b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

README

grcode

Decode QRCode in Go (wrapper of zbar)

Usage

see cmd/grcode/main.go

Credits

inspired by PeterCxy/gozbar.

Documentation

Index

Constants

View Source
const (
	ZBAR_NONE    = 0      /**< no symbol decoded */
	ZBAR_PARTIAL = 1      /**< intermediate status */
	ZBAR_EAN8    = 8      /**< EAN-8 */
	ZBAR_UPCE    = 9      /**< UPC-E */
	ZBAR_ISBN10  = 10     /**< ISBN-10 (from EAN-13). @since 0.4 */
	ZBAR_UPCA    = 12     /**< UPC-A */
	ZBAR_EAN13   = 13     /**< EAN-13 */
	ZBAR_ISBN13  = 14     /**< ISBN-13 (from EAN-13). @since 0.4 */
	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_QRCODE  = 64     /**< QR Code. @since 0.10 */
	ZBAR_CODE128 = 128    /**< Code 128 */
	ZBAR_SYMBOL  = 0x00ff /**< mask for base symbol type */
	ZBAR_ADDON2  = 0x0200 /**< 2-digit add-on flag */
	ZBAR_ADDON5  = 0x0500 /**< 5-digit add-on flag */
	ZBAR_ADDON   = 0x0700 /**< add-on flag mask */
	NONE         = C.ZBAR_NONE
	PARTIAL      = C.ZBAR_PARTIAL
	EAN8         = C.ZBAR_EAN8
	UPCE         = C.ZBAR_UPCE
	ISBN10       = C.ZBAR_ISBN10
	UPCA         = C.ZBAR_UPCA
	EAN13        = C.ZBAR_EAN13
	ISBN13       = C.ZBAR_ISBN13
	I25          = C.ZBAR_I25
	CODE39       = C.ZBAR_CODE39
	PDF414       = C.ZBAR_PDF417
	QRCODE       = C.ZBAR_QRCODE
	CODE128      = C.ZBAR_CODE128
	SYMBOL       = C.ZBAR_SYMBOL
	ADDON2       = C.ZBAR_ADDON2
	ADDON5       = C.ZBAR_ADDON5
	ADDON        = C.ZBAR_ADDON
)

following is reference from zbar.h

View Source
const VX_DF_IMAGE_Y800 = 0x30303859

VX_DF_IMAGE_Y800 is grayscale. Y800, GRAY is required

Variables

This section is empty.

Functions

func GetDataFromFile

func GetDataFromFile(imagePath string) (results []string, err error)

func GetDataFromImage

func GetDataFromImage(image image.Image) (results []string, err error)

GetDataFromImage read qrcode directly from golang Image class

Types

type RawData

type RawData string

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner is wrapper of zbar_image_scanner

func NewScanner

func NewScanner() *Scanner

NewScanner returns new Scanner

func (*Scanner) Close

func (s *Scanner) Close()

Close suicides

func (*Scanner) Scan

func (s *Scanner) Scan(img *ZbarImage) int

Scan scans image, the image format must be "Y800" or "GRAY". returns: >0, if symbols were successfully decoded from the image

0, if no symbols were found or

-1, if an error occurs

func (*Scanner) SetConfig

func (s *Scanner) SetConfig(symbology C.zbar_symbol_type_t, config C.zbar_config_t, value int) int

SetConfig sets scanner config 0 for success, non-0 for failure

type Symbol

type Symbol struct {
	// contains filtered or unexported fields
}

func NewSymbol

func NewSymbol(z *C.zbar_symbol_t) *Symbol

NewSymbol new the symbol object

func (*Symbol) Data

func (s *Symbol) Data() string

Data returns the string data of the symbol

func (*Symbol) Next

func (s *Symbol) Next() *Symbol

Next returns next symbol

func (*Symbol) Type

func (s *Symbol) Type() SymbolType

Type returns the symbol type

type SymbolType

type SymbolType struct {
	// contains filtered or unexported fields
}

func (SymbolType) IsQRCODE

func (t SymbolType) IsQRCODE() bool

type ZbarImage

type ZbarImage struct {
	// contains filtered or unexported fields
}

func NewZbarImage

func NewZbarImage(img image.Image) *ZbarImage

NewSymbol new the zbar image object

func (*ZbarImage) Close

func (z *ZbarImage) Close()

Close suicides

func (*ZbarImage) GetSymbol

func (z *ZbarImage) GetSymbol() *Symbol

GetSymbol returns the first symbol of result use symbol.Next() to retrive next

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL