-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
# qrcode-api | ||
A simple API service for QR Code generation/recognition | ||
|
||
# Compile | ||
|
||
Install and compile ZBar: | ||
|
||
```bash | ||
wget https://downloads.sourceforge.net/project/zbar/zbar/0.10/zbar-0.10.tar.bz2 | ||
tar -xf zbar-0.10.tar.bz2 | ||
cd zbar-0.10 | ||
export CFLAGS="" | ||
./configure --disable-video --without-imagemagick --without-qt --without-python --without-gtk --without-x --disable-pthread | ||
make install | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
LD_LIBRARY_PATH=/usr/local/lib ./qrcode-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2018 LI Zhennan | ||
* | ||
* Use of this work is governed by an MIT License. | ||
* You may find a license copy in project root. | ||
*/ | ||
|
||
package qrcode | ||
|
||
import ( | ||
"errors" | ||
"image" | ||
|
||
"github.com/PeterCxy/gozbar" | ||
) | ||
|
||
// DecodeQRCode decodes QR Code content from image | ||
// | ||
// content contains multiple string if there are more than one QR Code | ||
// got decoded. | ||
// content and err are both nil when no QR Code found. | ||
func DecodeQRCode(img image.Image) (content []string, err error) { | ||
input := zbar.FromImage(img) | ||
|
||
s := zbar.NewScanner() | ||
s.SetConfig(zbar.QRCODE, zbar.CFG_ENABLE, 1) | ||
result := s.Scan(input) | ||
|
||
if result < 0 { | ||
err = errors.New("error occurred when scanning") | ||
return | ||
} | ||
|
||
input.First().Each(func(item string) { | ||
content = append(content, item) | ||
}) | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters