qrcode

package module
v0.0.0-...-4269d70 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: GPL-3.0 Imports: 15 Imported by: 0

README

QR Code Decoder by Golang

This Project is Developing.

Plan

  1. Dynamic binarization
  2. Increase the speed of picture scanning: OK
  3. Fix the score: OK
  4. Fault tolerant code correction data: OK
  5. Data encoding method Numbert alphanumeric    8-bit byte: OK    Kanji
  6. Identify two-dimensional codes that are tilted at each angle

Example

fi, err := os.Open("qrcode.png")
if err != nil{
    logger.Println(err.Error())
    return
}
defer fi.Close()
qrmatrix, err := qrcode.Decode(fi)
if err != nil{
    logger.Println(err.Error())
    return
}
logger.Println(qrmatrix.Content)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlignmentPatternCenter = [][]int{
		{},
		{},
		{6, 18},
		{6, 22},
		{6, 26},
		{6, 30},
		{6, 34},
		{6, 22, 38},
		{6, 24, 42},
		{6, 26, 46},
		{6, 28, 50},
		{6, 30, 54},
		{6, 32, 58},
		{6, 34, 62},
		{6, 26, 46, 66},
		{6, 26, 48, 70},
		{6, 26, 50, 74},
		{6, 30, 54, 78},
		{6, 30, 56, 82},
		{6, 30, 58, 86},
		{6, 34, 62, 90},
		{6, 28, 50, 72, 94},
		{6, 26, 50, 74, 98},
		{6, 30, 54, 78, 102},
		{6, 28, 54, 80, 106},
		{6, 32, 58, 84, 110},
		{6, 30, 58, 86, 114},
		{6, 34, 62, 90, 118},
		{6, 26, 50, 74, 98, 122},
		{6, 30, 54, 78, 102, 126},
		{6, 26, 52, 78, 104, 130},
		{6, 30, 56, 82, 108, 134},
		{6, 34, 60, 86, 112, 138},
		{6, 30, 58, 86, 114, 142},
		{6, 34, 62, 90, 118, 146},
		{6, 30, 54, 78, 102, 126, 150},
		{6, 24, 50, 76, 102, 128, 154},
		{6, 28, 54, 80, 106, 132, 158},
		{6, 32, 58, 84, 110, 136, 162},
		{6, 26, 54, 82, 110, 138, 166},
		{6, 30, 58, 86, 114, 142, 170},
	}
	Versions = []QRcodeVersion{}/* 160 elements not displayed */

)
View Source
var Debug = false

Functions

func Bit2Byte

func Bit2Byte(bits []bool) byte

func Bit2Int

func Bit2Int(bits []bool) int

func Bits2Bytes

func Bits2Bytes(datacode []bool, version int) []byte

func Bool2Byte

func Bool2Byte(datacode []bool) []byte

func Byte2Bool

func Byte2Bool(bl []byte) []bool

func Copy

func Copy(src interface{}) interface{}

Copy creates a deep copy of whatever is passed to it and returns the copy in an interface{}. The returned value will need to be asserted to the correct type.

func ExportEveryGroup

func ExportEveryGroup(size image.Rectangle, kong [][]Pos, filename string)

func ExportGroup

func ExportGroup(size image.Rectangle, group []Pos, filename string)

func ExportGroups

func ExportGroups(size image.Rectangle, kong []*PosGroup, filename string)

func ExportMatrix

func ExportMatrix(size image.Rectangle, points [][]bool, filename string)

func GetData

func GetData(unmaskmatrix, dataarea *Matrix) []bool

func GetDataEncoder

func GetDataEncoder(version int) *dataEncoder

func IsPositionDetectionPattern

func IsPositionDetectionPattern(bukonggroup, konggroup *PosGroup) bool

func IsVertical

func IsVertical(kf, kl *K) (offset float64)

func Kong

func Kong(group *PosGroup) bool

func Line

func Line(start, end *Pos, matrix *Matrix) (line []bool)

func LineWidth

func LineWidth(positionDetectionPatterns [][]*PosGroup) float64

func MaskFunc

func MaskFunc(code int) func(x, y int) bool

func ParseBlock

func ParseBlock(m *Matrix, data []bool) []bool

func QRReconstruct

func QRReconstruct(data, ecc []byte) []byte

func Radian

func Radian(k *K)

func Rectangle

func Rectangle(group []Pos) (minx, maxx, miny, maxy int)

func SplitGroup

func SplitGroup(poss *[][]bool, centerx, centery int, around *[]Pos)

func StringBool

func StringBool(datacode []bool) string

func StringByte

func StringByte(b []byte) string

Types

type Block

type Block struct {
	NumBlocks int

	// Total codewords (NumCodewords == numErrorCodewords+NumDataCodewords).
	NumCodewords int

	// Number of data codewords.
	NumDataCodewords int
}

type K

type K struct {
	FirstPosGroup *PosGroup
	LastPosGroup  *PosGroup
	K             float64
}

type Matrix

type Matrix struct {
	OrgImage  image.Image
	OrgSize   image.Rectangle
	OrgPoints [][]bool
	Points    [][]bool
	Size      image.Rectangle
	Data      []bool
	Content   string
}

func Decode

func Decode(fi io.Reader) (*Matrix, error)

func DecodeImg

func DecodeImg(img image.Image) (*Matrix, error)

func (*Matrix) At

func (m *Matrix) At(x, y int) bool

func (*Matrix) Binarizat

func (matrix *Matrix) Binarizat() uint8

func (*Matrix) Centerlist

func (m *Matrix) Centerlist(line []bool, offset int) (li []int)

标线

func (*Matrix) DataArea

func (m *Matrix) DataArea() *Matrix

func (*Matrix) FormatInfo

func (m *Matrix) FormatInfo() (ErrorCorrectionLevel, Mask int)

func (*Matrix) GetBin

func (m *Matrix) GetBin(poss []Pos) int

func (*Matrix) ReadImage

func (matrix *Matrix) ReadImage()

func (*Matrix) SplitGroups

func (matrix *Matrix) SplitGroups() [][]Pos

func (*Matrix) Version

func (m *Matrix) Version() int

type Pos

type Pos struct {
	X int
	Y int
}

func CenterPoint

func CenterPoint(group []Pos) Pos

type PosGroup

type PosGroup struct {
	Group    []Pos
	GroupMap map[Pos]bool
	Min      Pos
	Max      Pos
	Center   Pos
	Kong     bool
}

func PossToGroup

func PossToGroup(group []Pos) *PosGroup

func PosslistToGroup

func PosslistToGroup(groups []*PosGroup) *PosGroup

type PositionDetectionPatterns

type PositionDetectionPatterns struct {
	Topleft *PosGroup
	Right   *PosGroup
	Bottom  *PosGroup
}

func NewPositionDetectionPattern

func NewPositionDetectionPattern(pdps [][]*PosGroup) *PositionDetectionPatterns

type QRcodeVersion

type QRcodeVersion struct {
	// Version number (1-40 inclusive).
	Version int

	// Error recovery Level.
	Level RecoveryLevel

	DataEncoderType dataEncoderType

	// Encoded data can be split into multiple blocks. Each Block contains data
	// and error recovery bytes.
	//
	// Larger QR Codes contain more blocks.
	Block []Block

	// Number of bits required to pad the combined data & error correction bit
	// stream up to the symbol's full capacity.
	NumRemainderBits int
}

QRcodeVersion describes the data length and encoding order of a single QR Code Version. There are 40 versions numbers x 4 recovery levels == 160 possible QRcodeVersion structures.

type RecoveryLevel

type RecoveryLevel int

Error detection/recovery capacity.

There are several levels of error detection/recovery capacity. Higher levels of error recovery are able to correct more errors, with the trade-off of increased symbol size.

const (
	// Level M: 15% error recovery. Good default choice. 0b00
	Medium RecoveryLevel = iota
	// Level L: 7% error recovery. 0b01
	Low
	// Level H: 30% error recovery.0b10
	Highest
	// Level Q: 25% error recovery.0b11
	High
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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