Exemple #1
0
def extract(filename):
    scanner = ImageScanner()
    scanner.set_config(0, Config.ENABLE, 0)
    scanner.set_config(Symbol.QRCODE, Config.ENABLE, 1)
    img = openImage(filename).convert('L')
    width, height = img.size
    raw = img.tostring()
    image = Image(width, height, 'Y800', raw)
    result = scanner.scan(image)

    if result == 0:
        return False
    else:
        result = False

        for symbol in image:
            if symbol.type == Symbol.QRCODE:
                result = symbol.data
                break

        del (image)
        return result
 def __init__(self, **kwargs):
     super(ScannerCamera, self).__init__(**kwargs)
     self._camera = None
     # create a scanner used for detecting qrcode
     self._scanner = ImageScanner()
     self._scanner.parse_config('enable')