Coder Social home page Coder Social logo

qrcode's Introduction

QR Code Decoder by Golang

This Project is Developing.

Plan

  1. 动态二值化:
  2. 提升图片扫描的速度 OK
  3. 修复标线取值 OK
  4. 容错码纠正数据 OK
  5. 数据编码方式
    Numbert
    alphanumeric OK
    8-bit byte OK
    Kanji
  6. 识别各角度倾斜的二维码

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)

qrcode's People

Contributors

cutereimu avatar ddzrc avatar jqs7 avatar lomoalbert 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

qrcode's Issues

好多都无法识别!!!

我想识别支付宝图片里面的二维码, 都无法识别, 只能用来识别只有二维码的情况, 带点边框就不行了

panic: lost PositionDetectionPattern

When the white in the image is adjusted to be transparent, it can not be resolved

github.com/tuotoo/qrcode.NewPositionDetectionPattern(0xc04209b8b8, 0x0, 0x0, 0x0)
    E:/Work/GoLib/src/github.com/tuotoo/qrcode/qrcode.go:175 +0x598
github.com/tuotoo/qrcode.DecodeImg(0x5b3e80, 0xc0420460c0, 0x0, 0x0, 0x0)

image: unknown format

func decode(writer http.ResponseWriter, request *http.Request) {
	imgUrl := request.URL.Query().Get("url")

	resp, err := http.Get(imgUrl)
	if err != nil {
		http.Error(writer, err.Error(), http.StatusInternalServerError)
		return
	}
	defer resp.Body.Close()

	//i, _, err := image.Decode(resp.Body)
	//if err != nil {
	//	log.Fatal(err)
	//}
	//fmt.Println(i.Bounds())

	qrMatrix, err := qrcode.Decode(request.Body)
	if err != nil {
		http.Error(writer, err.Error(), http.StatusInternalServerError)
		return
	}

	writer.Write([]byte(qrMatrix.Content))
}

This return an error: image: unknown format

上传一张非二维码的图片报错

2018/09/21 19:35:58 /code/uploadfile/src/github.com/tuotoo/qrcode/qrcode.go:264: /code/uploadfile/src/github.com/tuotoo/qrcode/qrcode.go 698 open groups/groups0.png: no such file or directory

panic: not found errorcorrectionlevel and mask

使用其他网站在线解码正常.

1

panic: not found errorcorrectionlevel and mask

goroutine 1 [running]:
github.com/tuotoo/qrcode.(*Matrix).FormatInfo(0xc04209c370, 0x0, 0x1a)
	F:/golang/get/src/github.com/tuotoo/qrcode/qrcode.go:78 +0x232
github.com/tuotoo/qrcode.Decode(0x7dafe0, 0xc042a18500, 0x63067e, 0x3, 0x630438)
	F:/golang/get/src/github.com/tuotoo/qrcode/qrcode.go:879 +0x19f
main.main()
	F:/golang/my/src/qr/mian.go:114 +0x676

qrcode.decode时出错

2019/10/13 08:01:25 [Recovery] 2019/10/13 - 08:01:25 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:82 (0x442480)
panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:390 (0x4422af)
sigpanic: panicmem()

decode errr

1.qrcode12.png,qrcode2.png,qrcode3.png 解码失败;
2.微信二维码解码失败;
3.json文本会发生解码失败。

panic: not found errorcorrectionlevel and mask

qr image url:https://s1.ax1x.com/2018/01/25/p7LQa9.jpg

goroutine 1 [running]:
github.com/tuotoo/qrcode.(*Matrix).FormatInfo(0xc0422a2000, 0x0, 0x32)
        E:/Work/GoLib/src/github.com/tuotoo/qrcode/qrcode.go:78 +0x232
github.com/tuotoo/qrcode.Decode(0x3514ff0, 0xc042156140, 0xc042156140, 0x3514ff0, 0xc042156140)
        E:/Work/GoLib/src/github.com/tuotoo/qrcode/qrcode.go:879 +0x18b
main.InitSSNode(0x765920, 0x29, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        E:/Work/GoWorkSpace/src/Orefa/ss/nutgeek/main.go:94 +0x115
main.main()
        E:/Work/GoWorkSpace/src/Orefa/ss/nutgeek/main.go:83 +0x52

panic: runtime error: index out of range

使用其他网站在线解码正常.

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/tuotoo/qrcode.(*Matrix).At(...)
	F:/golang/get/src/github.com/tuotoo/qrcode/qrcode.go:51
github.com/tuotoo/qrcode.DecodeImg(0x7df5a0, 0xc04203a180, 0x0, 0x0, 0x0)
	F:/golang/get/src/github.com/tuotoo/qrcode/qrcode.go:859 +0x18c0
github.com/tuotoo/qrcode.Decode(0x7dafe0, 0xc042fb9600, 0x63079e, 0x3, 0x630558)
	F:/golang/get/src/github.com/tuotoo/qrcode/qrcode.go:872 +0xdf
main.main()
	F:/golang/my/src/qr/mian.go:114 +0x69d

648

Example png in memory

Hello, Thanks for the work!
I'm here to leave an example of a read using an image.RGBA in memory, The following is the code of Image for bytes.Reader, reading directly from memory:

package main

import (
	"bytes"
	"fmt"
	"image"
	"image/png"
	"github.com/kbinani/screenshot"
	"github.com/tuotoo/qrcode"
)

func main() {

	img, err := screenshot.CaptureRect(image.Rect(0, 0, 40, 40))
	if err != nil {
		panic(err)
	}

	buff := new(bytes.Buffer)

	// encode image to buffer
	err = png.Encode(buff, img)
	if err != nil {
		fmt.Println("failed to create buffer", err)
	}

	// convert buffer to reader
	reader := bytes.NewReader(buff.Bytes())

	qrmatrix, err := qrcode.Decode(reader)

	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println("contend:")
	fmt.Println(qrmatrix.Content)
}

是不是不支持中文?

有中文的二维码图片直接报错

☁  run  go run .
2020/04/09 21:31:56 not found error correction level and mask

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.