Browse Source

fix ctypes for zbar qrcode scanner

seed_v14
ThomasV 7 years ago
parent
commit
f70408cef5
  1. 9
      lib/qrscanner.py

9
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)

Loading…
Cancel
Save