Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
/ goqr Public archive

QR Code recognition and decoding library in pure go

License

Notifications You must be signed in to change notification settings

liyue201/goqr

Repository files navigation

goqr

GoDoc Go Report Card Build Status Coverall License Example

This is a QR Code recognition and decoding library in pure go. It can recognize most of images into QR Code string.

Example

package main

import (
	"bytes"
	"fmt"
	"github.com/liyue201/goqr"
	"image"
	_ "image/jpeg"
	_ "image/png"
	"io/ioutil"
)

func recognizeFile(path string) {
	fmt.Printf("recognize file: %v\n", path)
	imgdata, err := ioutil.ReadFile(path)
	if err != nil {
		fmt.Printf("%v\n", err)
		return
	}

	img, _, err := image.Decode(bytes.NewReader(imgdata))
	if err != nil {
		fmt.Printf("image.Decode error: %v\n", err)
		return
	}
	qrCodes, err := goqr.Recognize(img)
	if err != nil {
		fmt.Printf("Recognize failed: %v\n", err)
		return
	}
	for _, qrCode := range qrCodes {
		fmt.Printf("qrCode text: %s\n", qrCode.Payload)
	}
}

func main() {
	recognizeFile("testdata/008.png")
}

About

QR Code recognition and decoding library in pure go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages