From f70408cef5eff3eead108a06ee11a6106253f74d Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 25 Aug 2017 11:23:11 +0200 Subject: [PATCH] fix ctypes for zbar qrcode scanner --- lib/qrscanner.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/qrscanner.py b/lib/qrscanner.py index 80d4adb94..c0af98ce4 100644 --- a/lib/qrscanner.py +++ b/lib/qrscanner.py @@ -25,7 +25,7 @@ import os import sys -from ctypes import cdll, c_char_p +import ctypes if sys.platform == 'darwin': name = 'libzbar.dylib' @@ -35,7 +35,7 @@ else: name = 'libzbar.so.0' try: - libzbar = cdll.LoadLibrary(name) + libzbar = ctypes.cdll.LoadLibrary(name) except OSError: libzbar = None @@ -43,7 +43,10 @@ except OSError: def scan_barcode(device='', timeout=-1, display=True, threaded=False): if libzbar is None: raise RuntimeError("Cannot start QR scanner; zbar not available.") - libzbar.zbar_symbol_get_data.restype = c_char_p + libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p + libzbar.zbar_processor_create.restype = ctypes.POINTER(ctypes.c_int) + libzbar.zbar_processor_get_results.restype = ctypes.POINTER(ctypes.c_int) + libzbar.zbar_symbol_set_first_symbol.restype = ctypes.POINTER(ctypes.c_int) proc = libzbar.zbar_processor_create(threaded) libzbar.zbar_processor_request_size(proc, 640, 480) libzbar.zbar_processor_init(proc, device, display)