fix ctypes for zbar qrcode scanner
This commit is contained in:
parent
7ed79011fe
commit
f70408cef5
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from ctypes import cdll, c_char_p
|
import ctypes
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
name = 'libzbar.dylib'
|
name = 'libzbar.dylib'
|
||||||
|
@ -35,7 +35,7 @@ else:
|
||||||
name = 'libzbar.so.0'
|
name = 'libzbar.so.0'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
libzbar = cdll.LoadLibrary(name)
|
libzbar = ctypes.cdll.LoadLibrary(name)
|
||||||
except OSError:
|
except OSError:
|
||||||
libzbar = None
|
libzbar = None
|
||||||
|
|
||||||
|
@ -43,7 +43,10 @@ except OSError:
|
||||||
def scan_barcode(device='', timeout=-1, display=True, threaded=False):
|
def scan_barcode(device='', timeout=-1, display=True, threaded=False):
|
||||||
if libzbar is None:
|
if libzbar is None:
|
||||||
raise RuntimeError("Cannot start QR scanner; zbar not available.")
|
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)
|
proc = libzbar.zbar_processor_create(threaded)
|
||||||
libzbar.zbar_processor_request_size(proc, 640, 480)
|
libzbar.zbar_processor_request_size(proc, 640, 480)
|
||||||
libzbar.zbar_processor_init(proc, device, display)
|
libzbar.zbar_processor_init(proc, device, display)
|
||||||
|
|
Loading…
Reference in New Issue