Giter Club home page Giter Club logo

gozxing's People

Contributors

eliasnaur avatar makiuchi-d avatar tbuchaillot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gozxing's Issues

Implement UPC/EAN Writers

  • UPCAWriter
    • EAN13Writer
  • UPCEWriter
    • UPCEANWriter
    • UPCEANReader
  • EAN13Writer
    • UPCEANWriter
    • UPCEANReader
  • EAN8Writer
    • UPCEANWriter
    • UPCEANReader
  • UPCEANWriter
    • OneDimensionalCodeWriter
  • OneDimensionalCodeWriter

Implement DataMatrixWriter

dependencies:

  • datamatrix.DataMatrixWriter
    • Dimension
    • datamatrix.encoder.DefaultPlacement
    • datamatrix.encoder.ErrorCorrection
    • datamatrix.encoder.HighLevelEncoder
    • datamatrix.encoder.SymbolInfo
    • datamatrix.encoder.SymbolShapeHint
    • qrcode.encoder.ByteMatrix
  • Dimension
  • datamatrix.encoder.DefaultPlacement
  • datamatrix.encoder.ErrorCorrection
    • datamatrix.encoder.SymbolInfo
  • datamatrix.encoder.HighLevelEncoder
    • Dimension
    • datamatrix.encoder.SymbolShapeHint
    • datamatrix.encoder.ASCIIEncoder
    • datamatrix.encoder.C40Encoder
    • datamatrix.encoder.TextEncoder
    • datamatrix.encoder.X12Encoder
    • datamatrix.encoder.EdifactEncoder
    • datamatrix.encoder.Base256Encoder
    • datamatrix.encoder.EncoderContext
  • datamatrix.encoder.SymbolInfo
    • datamatrix.encoder.DataMatrixSymbolInfo144
    • datamatrix.encoder.SymbolShapeHint
    • Dimension
  • datamatrix.encoder.SymbolShapeHint
  • datamatrix.encoder.ASCIIEncoder
    • datamatrix.encoder.Encoder
    • datamatrix.encoder.HighLevelEncoder
    • datamatrix.encoder.EncoderContext
  • datamatrix.encoder.C40Encoder
    • datamatrix.encoder.Encoder
    • datamatrix.encoder.HighLevelEncoder
    • datamatrix.encoder.EncoderContext
  • datamatrix.encoder.TextEncoder
    • datamatrix.encoder.C40Encoder
    • datamatrix.encoder.HighLevelEncoder
  • datamatrix.encoder.X12Encoder
    • datamatrix.encoder.C40Encoder
    • datamatrix.encoder.HighLevelEncoder
    • datamatrix.encoder.EncoderContext
  • datamatrix.encoder.EdifactEncoder
    • datamatrix.encoder.Encoder
    • datamatrix.encoder.HighLevelEncoder
    • datamatrix.encoder.EncoderContext
  • datamatrix.encoder.Base256Encoder
    • datamatrix.encoder.Encoder
    • datamatrix.encoder.HighLevelEncoder
    • datamatrix.encoder.EncoderContext
  • datamatrix.encoder.EncoderContext
    • Dimension
    • datamatrix.encoder.SymbolShapeHint
    • datamatrix.encoder.SymbolInfo
  • datamatrix.encoder.DataMatrixSymbolInfo144
    • datamatrix.encoder.SymbolInfo
  • datamatrix.encoder.Encoder
    • datamatrix.encoder.EncoderContext

NotFoundException: startSize = 0

Could you please check, why qrReader.Decode(img, nil) returns error "NotFoundException: startSize = 0"?

#24
img3

File is attached, QR-code looks normal.
Online version doesn't decode it too.

error: NotFoundException: dimension = 63

this is my code, the error occur in the last row:

func helloworld(c *gin.Context) {
		file, _ := c.FormFile("file")
		log.Println(file.Filename)
		fileDetail, err := file.Open()
		if err != nil {
			c.JSON(http.StatusBadRequest, PostScanSettlementReply{
				Status: http.StatusBadRequest,
				Msg:    "error: i" + err.Error(),
			})
			return
		}
		img, _, err := image.Decode(fileDetail)
		if err != nil {
			logcat.Log().Sugar().Error("image decode error, the error is ", err.Error())
			c.JSON(http.StatusBadRequest, PostScanSettlementReply{
				Status: http.StatusBadRequest,
				Msg:    "error: " + err.Error(),
			})
			return
		}

		// prepare BinaryBitmap
		bmp, _ := gozxing.NewBinaryBitmapFromImage(img)

		// decode image
		qrReader := qrcode.NewQRCodeReader()
		result, err := qrReader.Decode(bmp, nil)
                //...... more code
}

The qrcode is
abcc

FNC1 in Datamatrix

How to add FNC1 character to the beginning of datamatrix code?
Hint gozxing.EncodeHintType_GS1_FORMAT not work in datamatrix writer

cannot decode a qrcode

I try to decode a qrcode, but I cannot decode it.
it give me a error

NotFoundException

but actully it is a normal qrcode, this is my pic.
QR

that my code:

func DecodeFile(fi string)(string, error) {
	file, _ := os.Open(fi)
	img, _, _:= image.Decode(file)
	// prepare BinaryBitmap
	bmp, _:= gozxing.NewBinaryBitmapFromImage(img)
	// decode image
	result, err := qrcode.NewQRCodeReader().Decode(bmp, nil)
	if err != nil {
		return "", err
	}
	return result.String(), nil
}

Barcode recognition on scanned pages

Hi @makiuchi-d,

First off, thank you for such a great library!

I have a question. In a scenario of scanning documents, where the content area is large and barcode presence percentage is relatively small, what might be a recommended approach? Using scanned pages' images as is doesn't work, no barcodes are found on a page. As a workaround, I used cropping the image leaving only top-right area (a potential place of a barcode) for example. That worked, but I'm not sure, probably there is some more robust approach embedded to the library which I just missed?

Unable to decode some QR codes

Hi
Thanks for the library first. It's working well. However for some QR codes it doesn't able to find QR codes. I've also tried some hints e.g. Try harder. But it doesn't work. The code I've been trying with is;

`bmp, err := gozxing.NewBinaryBitmap(gozxing.NewGlobalHistgramBinarizer(gozxing.NewLuminanceSourceFromImage(img)))
hints := map[gozxing.DecodeHintType]interface{}{
gozxing.DecodeHintType_TRY_HARDER: true,
gozxing.DecodeHintType_POSSIBLE_FORMATS: []gozxing.BarcodeFormat{
gozxing.BarcodeFormat_QR_CODE},
}

// decode image
qrReader := qrcode.NewQRCodeReader()
result, err := qrReader.Decode(bmp, hints)`

And the QR codes, which doesn't decode/detected are the following.
d7p

Can't read qrcodes from github.com/chai2010/qrcode

Hey makiuchi,

Thank you for the great and active development!
I am currently trying to generate and read qr codes within Go.

The only kinda fast encoding library I found was at github.com/chai2010/qrcode. However, the decoding from the wrapped libqrencode is unable to read the codes generated by itself, as can be seen here: chai2010/qrcode#2

I generated a sample file with the maximum bytes:
QRCode

As the online version of Zxing was able to read it (it's just "Hello World. " repeatedly), I hoped that this library can read it. Sadly, it doesn't.

Do you know

  1. Why decoding doesn't work?
  2. What's your recommended approach to quickly encode & decode qr codes, if the issue is within the encoding library?

Implement RSS14Reader

RSS14Reader

  • oned.rss.RSS14Reader
    • oned.rss.AbstractRSSReader
    • oned.rss.Pair
    • oned.rss.FinderPattern
    • oned.rss.DataCharacter
    • oned.rss.RSSUtils
  • oned.rss.AbstractRSSReader
    • oned.OneDReader
  • oned.rss.Pair
    • oned.rss.DataCharacter
    • oned.rss.FinderPattern
  • oned.rss.FinderPattern
  • oned.rss.DataCharacter
  • oned.rss.RSSUtils

Implement qrcode.detector.Detector

This issue related to #1

Dependencies of qrcode.detector.Detector:

  • DecodeHintType
  • FormatException
  • NotFoundException
  • ResultPoint
    • common.detector.MathUtil
  • ResultPointCallback
  • common.BitMatrix
    • common.BitArray
  • common.DetectorResult
    • ResultPoint
    • common.BitMatrix
  • common.GridSampler
    • NotFoundException
    • common.DefaultGridSampler
    • common.BitMatrix
    • common.PerspectiveTransform
  • common.PerspectiveTransform
  • common.DefaultGridSampler
    • NotFoundException
    • common.GridSampler
    • common.PerspectiveTransform
    • common.BitMatrix
  • common.detector.MathUtils
  • qrcode.decoder.Version
    • FormatException
    • common.BitMatrix
    • qrcode.decoder.ErrorCorrectionLevel
    • qrcode.decoder.FormatInformation
  • qrcode.decoder.ErrorCorrectionLevel
  • qrcode.detector.FinderPatternFinder
    • DecodeHintType
    • NotFoundException
    • ResultPoint
    • ResultPointCallback
    • common.BitMatrix
    • FinderPatternInfo
    • FinderPattern
  • qrcode.detector.FinderPatternInfo
    • qrcode.detector.FinderPattern
  • qrcode.detector.FinderPattern
    • ResultPoint
  • qrcode.detector.AlignmentPattern
    • ResultPoint
  • qrcode.detector.AlignmentPatternFinder
    • NotFoundException
    • ResultPointCallback
    • common.BitMatrix
  • qrcode.detector.Detector

Implement UPC/EAN Readers

Dependencies:

  • UPCAReader
    • UPCEANReader
    • EAN13Reader
  • UPCEReader
    • UPCEANReader
  • EAN13Reader
    • UPCEANReader
  • EAN8Reader
    • UPCEANReader
  • UPCEANReader
    • OneDReader
    • UPCEANExtensionSupport
    • EANManufacturerOrgSupport
  • UPCEANExtensionSupport
    • UPCEANExtension2Support
    • UPCEANExtension5Support
  • EANManufacturerOrgSupport
  • UPCEANExtension2Support
    • UPCEANReader
  • UPCEANExtension5Support
    • UPCEANReader
  • OneDReader

NotFoundException: startSize = 0

"errVerbose":"NotFoundException: startSize = 0:
qukan-ugc/vendor/github.com/makiuchi-d/gozxing/qrcode/detector.(*FinderPatternFinder).SelectBestPatterns
/data/jenkins/home/workspace/techcenter_content_server-ugc-api/src/qukan-ugc/vendor/github.com/makiuchi-d/gozxing/qrcode/detector/finder_pattern_finder.go:459

PDF417

Is there plans to port PDF417?

Can't decode qr, but zxing online decode correctly

First of all, thanks for this great pure go port.

I'm having a problem with a qr extracted from a pdf, I'm saving it to a jpg before trying to decode

imagen

The code I'm using is this

qrImage := args[0]
qrFile, _ := os.Open(qrImage)
img, _, _ := image.Decode(qrFile)

bmp, err := gozxing.NewBinaryBitmapFromImage(img)
handleError(err) // this only print the error

qrReader := qrcode.NewQRCodeReader()
result, err := qrReader.Decode(bmp, nil)
handleError(err)

fmt.Println(result)

This code is showing not found exception, but zxing online shows the following

imagen

I try also with hints (maybe I'm doing it wrong)

hints :=  map[gozxing.DecodeHintType]interface{}{
	gozxing.DecodeHintType_PURE_BARCODE: true,
	gozxing.DecodeHintType_POSSIBLE_FORMATS: []gozxing.BarcodeFormat{
		gozxing.BarcodeFormat_DATA_MATRIX },
}
result, err := qrReader.Decode(bmp, hints)

with format exception.

Need some help, because the users will be loading the pdf dynamically

error while parsing qr code image

I am getting error while trying to parse qr code png image.

"NotFoundException: (w, h) = (492, 492), (x, y) = (63, -7)"
is the error message I am getting.

I am sorry, I cant attach the sample QR code with you.

code

f, _ = ioutils.ReadFile(filepath)
require.NoError(t, err)
img, _, err := image.Decode(f)
require.NoError(t, err)

bmp, err := gozxing.NewBinaryBitmapFromImage(img)
require.NoError(t, err)
// decode image
qrReader := qrcode.NewQRCodeReader()
result, err := qrReader.Decode(bmp, nil)
require.NoError(t, err) // Error is thrown here.

NotFoundException: dimension = 75

My QR Code like this:
image

when use Decode, this error happened:
qrcode.NewQRCodeReader().Decode error:NotFoundException: dimension = 75

What could be the reason?

This QR Code picture can be scanned by WeChat to get the result.

decode panic

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0xbf0648]

goroutine 1 [running]:
github.com/makiuchi-d/gozxing.NewLuminanceSourceFromImage({0x0, 0x0})
	D:/Program Files/GOPATH/pkg/mod/github.com/makiuchi-d/[email protected]/go_image_luminance_source.go:19 +0x28
github.com/makiuchi-d/gozxing.NewBinaryBitmapFromImage({0x0?, 0x0?})
	D:/Program Files/GOPATH/pkg/mod/github.com/makiuchi-d/[email protected]/go_image_luminance_source.go:10 +0x27

here is my code

func main() {
	// open and decode image file
	file, _ := os.Open("D:\\AppData\\Local\\Temp\\123.jpg")
	img, _, _ := image.Decode(file)

	// prepare BinaryBitmap
	bmp, _ := gozxing.NewBinaryBitmapFromImage(img)

	// decode image
	qrReader := qrcode.NewQRCodeReader()
	result, _ := qrReader.Decode(bmp, nil)

	fmt.Println(result)
}

Version tags

Could you add version tags to this module to indicate release stability? I'd be happy to help you out with setting this up, as well as some GitHub Actions automation for releases when a new tag is pushed.

QR decoding of this file does not find a code. Scanners (Android, online) find it.

The attached PNG file cannot be detected by the lib. What am I doing wrong?

func Decode(data []byte) (string, error) {
	img, err := png.Decode(bytes.NewReader(data))
	if err != nil {
		return "", ErrNotPNG
	}
	// prepare BinaryBitmap
	bmp, err := gozxing.NewBinaryBitmapFromImage(img)
	if err != nil {
		return "", ErrNotPNG
	}
	// decode image
	qrReader := qr1.NewQRCodeReader()
	result, err := qrReader.Decode(bmp, nil)
	if err != nil {
		return "", ErrNotQRCode
	}
	return result.GetText(), nil
}```
![qr](https://user-images.githubusercontent.com/39924160/227664064-a9c716f0-1907-49da-8f15-3a60cb2a0150.png)

Runtime error on encode cyrillic letters

Hello! I'm trying to make datamatrix code for Cyrillic

text := "Mосква"
datamatrixWriter := datamatrix.NewDataMatrixWriter()
datamatrixCode, _ := datamatrixWriter.Encode(text, gozxing.BarcodeFormat_DATA_MATRIX, 648, 648, nil)

and Windows1251 ("Ìîñêâà"):

text := "Mосква"
enc := charmap.Windows1251.NewEncoder()
win1251text, _ := enc.String(text)
datamatrixWriter := datamatrix.NewDataMatrixWriter()
datamatrixCode, _ := datamatrixWriter.Encode(win1251text, gozxing.BarcodeFormat_DATA_MATRIX, 648, 648, nil)

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x12f2e63]

github.com/makiuchi-d/gozxing/datamatrix/encoder.(*EncoderContext).SetSymbolShape(...)
/go/src/github.com/makiuchi-d/gozxing/datamatrix/encoder/encoder_context.go:42
github.com/makiuchi-d/gozxing/datamatrix/encoder.EncodeHighLevel(0x13ed327, 0x4, 0x0, 0x0, 0x0, 0xc0001024b0, 0x34, 0xc000000076, 0xc0000b4078, 0x10c2240)
/go/src/github.com/makiuchi-d/gozxing/datamatrix/encoder/high_level_encoder.go:116 +0x1a3
github.com/makiuchi-d/gozxing/datamatrix.(*DataMatrixWriter).Encode(0x172ad30, 0x13ed327, 0x4, 0x5, 0x288, 0x288, 0x0, 0x0, 0x0, 0x140695a)
/go/src/github.com/makiuchi-d/gozxing/datamatrix/datamatrix_writer.go:61 +0x2ac
main.createRPImageContext(0x13ef3bd, 0x9, 0x0, 0x829749600, 0x0, 0x140695a, 0x60, 0x140695a, 0x60, 0x140695a, ...)

Implement QRCodeWriter

Dependencies:

  • BarcodeFormat
  • EncodeHintType
  • Writer
    • WriterException
    • BarcodeFormat
    • EncodeHintType
  • WriterException
  • common.BitMatrix
  • qrcode.decoder.ErrorCorrectionLevel
  • qrcode.encoder.ByteMatrix
  • qrcode.encoder.Encoder
    • EncodeHintType
    • WriterException
    • common.BitArray
    • common.CharacterSetECI
    • common.reedsolomon.GenericGF
    • common.reedsolomon.ReedSolomonEncoder
    • qrcode.decoder.ErrorCorrectionLevel
    • qrcode.decoder.Mode
    • qrcode.decoder.Version
    • qrcode.encoder.ByteMatrix
    • qrcode.encoder.QRCode
    • qrcode.encoder.BlockPair
    • qrcode.encoder.MaskUtil
    • qrcode.encoder.MatrixUtil
  • qrcode.encoder.QRCode
    • qrcode.decoder.ErrorCorrectionLevel
    • qrcode.decoder.Mode
    • qrcode.decoder.Version
    • qrcode.encoder.ByteMatrix
  • qrcode.encoder.BlockPair
  • qrcode.encoder.MaskUtil
    • qrcode.encoder.ByteMatrix
  • qrcode.encoder.MatrixUtil
    • WriterException
    • common.BitArray
    • qrcode.decoder.ErrorCorrectionLevel
    • qrcode.decoder.Version
    • qrcode.encoder.ByteMatrix
  • common.reedsolomon.ReedSolomonEncoder
    • common.reedsolomon.GenericGF
    • common.reedsolomon.GenericGFPoly

Implement qrcode.decoder.Decoder

This issue related to #1

Dependencies of qrcode.decoder.Decoder:

  • ChecksumException
    • ReaderException
  • ReaderException
  • DecodeHintType
  • FormatException
  • common.BitMatrix
  • common.BitSource
  • common.CharacterSetECI
    • FormatException
  • common.DecoderResult
  • common.StringUtils
    • DecodeHintType
  • common.reedsolomon.GenericGF
    • common.reedsolomon.GenericGFPoly
  • common.reedsolomon.GenericGFPoly
    • common.reedsolomon.GenericGF
  • common.reedsolomon.ReedSolomonDecoder
    • common.reedsolomon.GenericGF
    • common.reedsolomon.GenericGFPoly
    • common.reedsolomon.ReedSolomonException
  • common.reedsolomon.ReedsolomonException
  • qrcode.decoder.BitMatrixParser
    • FormatException
    • common.BitMatrix
    • qrcode.decoder.Version
    • qrcode.decoder.FormatInformation
    • qrcode.decoder.DataMask
  • qrcode.decoder.FormatInformation
    • qrcode.decoder.ErrorCorrectionLevel
  • qrcode.decoder.DataMask
    • common.BitMatrix
  • qrcode.decoder.ErrorCorrectionLevel
  • qrcode.decoder.QRCodeDecoderMetaData
    • ResultPoint
  • qrcode.decoder.Version
    • FormatException
    • common.BitMatrix
    • qrcode.decoder.ErrorCorrectionLevel
  • qrcode.decoder.DataBlock
    • qrcode.decoder.ErrorCorrectionLevel
  • qrcode.decoder.DecodedBitStreamParser
    • DecodeHintType
    • FormatException
    • common.BitSource
    • common.CharacterSetECI
    • common.DecoderResult
    • common.StringUtils
    • qrcode.decoder.Version
    • qrcode.decoder.ErrorCorrectionLevel
    • qrcode.decoder.Mode
  • qrcode.decoder.Mode
  • qrcode.decoder.Decoder

Code128 - Problem with FNC1/FNC2/FNC3

I need to play with Code128 and FNC3, but ... facing some troubles...

From the sources, I understand my code should look like :

        ...
	data := "\u00f3FOO"
	writer := oned.NewCode128Writer()
	bmx, err := writer.Encode(data, gozxing.BarcodeFormat_CODE_128, w, h, nil)
	if err != nil {
		fmt.Printf("Encoder error : %s\n", err)
                return err
	}
	...

With the code above, I get an error like : Bad character in input: 195

I had deeper look to code128 encoder and I suspect a bug in this area:

	for i := 0; i < length; i++ {
		c := contents[i]
		switch c {
		case code128ESCAPE_FNC_1, code128ESCAPE_FNC_2, code128ESCAPE_FNC_3, code128ESCAPE_FNC_4:
			break
		default:
			if c > 127 {
				// support for FNC4 isn't implemented, no full Latin-1 character set available at the moment
				return nil, gozxing.NewWriterException(
					"IllegalArgumentException: Bad character in input: %v", c)
			}
		}
	}

With traces inserted, none of the case code128ESCAPE_FNC_x are hit.

I suspect a kind of problem like in the playground : https://play.golang.org/p/cfPXCJsBN3a

Implement DataMatrixReader

dependencies:

  • datamatrix.DataMatrixReader
    • datamatrix.decoder.Decoder
    • datamatrix.detector.Detector
  • datamatrix.decoder.Decoder
    • datamatrix.decoder.BitMatrixParser
    • datamatrix.decoder.Version
    • datamatrix.decoder.DataBlock
    • datamatrix.decoder.DecodedBitStreamParser
  • datamatrix.decoder.BitMatrixParser
    • datamatrix.decoder.Version
  • datamatrix.decoder.Version
    • datamatrix.decoder.Version.ECBlocks
    • datamatrix.decoder.Version.ECB
  • datamatrix.decoder.DataBlock
    • datamatrix.decoder.Version
    • datamatrix.decoder.Version.ECBlocks
    • datamatrix.decoder.Version.ECB
  • datamatrix.decoder.DecodedBitStreamParser
  • datamatrix.detector.Detector
    • common.detector.WhiteRectangleDetector
    • datamatrix.detector.ResultPointsAndTransitions
  • common.detector.WhiteRectangleDetector

Implement QRCodeMultiReader

  • multi.qrcode.QRCodeMultiReader
    • multi.MultipleBarcodeReader
    • multi.qrcode.detector.MultiDetector
  • multi.MultipleBarcodeReader
  • multi.qrcode.detector.MultiDetector
    • multi.qrcode.detector.MultiFinderPatternFinder
  • multi.qrcode.detector.MultiFinderPatternFinder

Cannot decode qr code image

Hi, I have a problem with decode this image that contains qr code
qr

My code is the follow and i can decode the image with online zxing web app.

func qrDecoder(localQrPath string) (*gozxing.Result,error) {
	// open and decode image file
	file, err := os.Open(localQrPath)
	if err != nil {
		return nil,err
	}
	img, _, err := image.Decode(file)
	if err != nil {
		return nil,err
	}
	src := gozxing.NewLuminanceSourceFromImage(img)
	// prepare BinaryBitmap
	bmp, err := gozxing.NewBinaryBitmap(gozxing.NewGlobalHistgramBinarizer(src))
	if err != nil {
		return nil,err
	}
	// decode image
	hints :=  map[gozxing.DecodeHintType]interface{}{
		//gozxing.EncodeHintType_ERROR_CORRECTION: decoder.ErrorCorrectionLevel_L,
		gozxing.DecodeHintType_TRY_HARDER: true,
		gozxing.DecodeHintType_POSSIBLE_FORMATS: []gozxing.BarcodeFormat{
			gozxing.BarcodeFormat_QR_CODE },
	}
	qrReader := qrcode.NewQRCodeReader()
	return qrReader.Decode(bmp, hints)
}

It return "image: unknown format" error.

not support large image

raw qrcode

https://github.com/makiuchi-d/gozxing

when size large then 4000x4000 return "NotFoundException: startSize = x:"

test

panic: runtime error: invalid memory address or nil pointer dereference

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x4b60be]

goroutine 1 [running]:
github.com/makiuchi-d/gozxing.NewLuminanceSourceFromImage(0x0, 0x0, 0xc00007e070, 0x0)
C:/src/go_work/src/github.com/makiuchi-d/gozxing/go_image_luminance_source.go:19 +0x3e
github.com/makiuchi-d/gozxing.NewBinaryBitmapFromImage(0x0, 0x0, 0x0, 0x0, 0x0)
C:/src/go_work/src/github.com/makiuchi-d/gozxing/go_image_luminance_source.go:10 +0x40
main.main()
C:/src/go_work/src/learning/qrcode.go:36 +0x85
exit status 2



package main

import (
	"fmt"
	"image"
	_ "image/jpeg"
	"os"

	"github.com/makiuchi-d/gozxing"
	"github.com/makiuchi-d/gozxing/qrcode"
)

func main() {
	// open and decode image file
	file, _ := os.Open("qr.png")
	img, _, _ := image.Decode(file)

	// prepare BinaryBitmap
	bmp, _ := gozxing.NewBinaryBitmapFromImage(img)

	// decode image
	qrReader := qrcode.NewQRCodeReader()
	result, _ := qrReader.Decode(bmp, nil)

	fmt.Println(result)
}

QRCodeReader sometimes fails to extract a qr code from an image

The QRCodeReader fails to extract the QR code from the attached image:
img_0448

It responds with a NotFoundException
Go snippet:

...
img, _, _ := image.Decode(file)
bmp, _ := gozxing.NewBinaryBitmapFromImage(img)
qrReader := qrcode.NewQRCodeReader()
result, err := qrReader.Decode(bmp, nil)
...

The Java equivalent (https://github.com/zxing/zxing) on the other hand is able to do it
Java snippet:

...
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
Reader reader = new QRCodeReader();
Result theResult = reader.decode(bitmap, null);
...

Implement QRCodeReader

Dependencies of qrcode.QRCodeReader:

  • BarcodeFormat
  • BinaryBitmap
    • common.BitArray
    • common.BitMatrix
    • NotFoundException
    • Binarizer
    • LuminanceSource
  • Binarizer
    • common.BitArray
    • common.BitMatrix
    • LuminanceSource
    • NotFoundException
  • LuminanceSource
    • InvertedLuminanceSource
  • InvertedLuminanceSource
    • LuminanceSource
  • ChecksumException
    • ReaderException
  • ReaderException
  • DecodeHintType
  • FormatException
  • NotFoundException
  • Reader
    • BinaryBitmap
    • NotFoundException
    • ChecksumException
    • FormatException
    • Result
  • Result
    • ResultPoint
    • BarcodeFormat
    • ResultMetadataType
  • ResultMetadataType
  • ResultPoint
    • common.detector.MathUtil
  • common.detector.MathUtil
  • common.BitMatrix
    • common.BitArray
  • common.DetectorResult
    • ResultPoint
    • common.BitMatrix
  • qrcode.decoder.Decoder
  • qrcode.decoder.QRCodeDecoderMetaData
    • ResultPoint
  • qrcode.detector.Detector

Datamatrix reader programming

Is there a plan to implement "reader programming" support with Datamatrix ?

Got something, working with Datalogic scanners ...
in case ...

qrcode encode error: extra 1 byte at start

Usage:

ctx is a web server response context, just ignore it.

                encoder := qrcode.NewQRCodeWriter()
		btmtrx, err := encoder.Encode(yearInt+"|"+nanoId, gozxing.BarcodeFormat_QR_CODE, 300, 300, nil)
		finalBuf := bytes.NewBuffer(nil)
		_ = png.Encode(finalBuf, btmtrx)
		ctx.SetStatusCode(200)
		ctx.Response.Header.Set("Content-disposition", "attachment; filename=qrcode.png")
		ctx.SetContentType("application/octet-stream")
		ctx.SetBody(finalBuf.Bytes())

After downloaded, the file cannot be open.

One extra byte here:

00000000: c289 504e 470d 0a1a 0a00 0000 0d49 4844  ..PNG........IHD

The binwalk result is:

mypc% binwalk /tmp/h1.png

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
1             0x1             PNG image, 300 x 300, 8-bit grayscale, non-interlaced

After stripped the first extra byte, the file is attached here.

h1

ChecksumException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.