0
0

More than 1 year has passed since last update.

ブラウザでjancodeを認識したい

Posted at

動機

socket.io を介してzbarで認識させれば、できそうなのでやってみました

ブラウザ上での認識率比較

zxing < zbar < dynasoft

インストール

sudo apt install libzbar0
pip3 install pyzbar
pip3 install flask
pip3 install flask-socket.io

スクリプト

Jsとpythonのやりとり部分は、この記事と同じです
https://qiita.com/im02kai/items/e460fa86be1501474275

zbar用に変更

app.py
from pyzbar.pyzbar import decode

@socketio.event
def image_barcode(img_base64):#base64

    im = Image.open(io.BytesIO(base64.b64decode(img_base64.split(',')[1])))
    data = decode(im)

    if data != []:
        str=data[0][0].decode('utf-8', 'ignore')
        print(str)

        (x, y, w, h) = data[0].rect

        emit('my_response',{
            'code': str,
            'x': x,
            'y': y,
            'w': w,
            'h': h
            }
        )
    else:
        print("Image is empty!!")
        emit('error',{'code': '0000'}
        )


テストサイト

Yahoo Shopping Apiと連携してみました
認識率のテストでご利用ください

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0