python demo解决c_ulong和.h文件不统一的问题
This commit is contained in:
parent
01f18256e5
commit
97853a8b88
|
@ -6,10 +6,10 @@ import platform
|
|||
from ctypes import *
|
||||
|
||||
class HGLibSaveImageParam(Structure):
|
||||
_fields_ = [ ("size", c_ulong),
|
||||
("jpegQuality", c_ulong),
|
||||
("tiffCompression", c_ulong),
|
||||
("tiffJpegQuality", c_ulong),
|
||||
_fields_ = [ ("size", c_uint),
|
||||
("jpegQuality", c_uint),
|
||||
("tiffCompression", c_uint),
|
||||
("tiffJpegQuality", c_uint),
|
||||
("ocr", c_int)]
|
||||
|
||||
print(os.path.abspath('.'))
|
||||
|
@ -45,12 +45,12 @@ HGLib_ReleaseImage.restype = ctypes.c_int
|
|||
Ret = HGLib_ReleaseImage(Image)
|
||||
|
||||
#设备热拔插回调事件
|
||||
def HGLibDeviceHotPlugEventFunc(event: c_ulong, deviceName: c_char_p, param: c_void_p):
|
||||
def HGLibDeviceHotPlugEventFunc(event: c_uint, deviceName: c_char_p, param: c_void_p):
|
||||
print(deviceName)
|
||||
return
|
||||
|
||||
#初始化操作
|
||||
FuncType = CFUNCTYPE(None, c_ulong, c_char_p, c_void_p)
|
||||
FuncType = CFUNCTYPE(None, c_uint, c_char_p, c_void_p)
|
||||
cb = FuncType(HGLibDeviceHotPlugEventFunc)
|
||||
HGLib_InitDevice = Objdll.HGLib_InitDevice
|
||||
HGLib_InitDevice.argtypes = [FuncType, c_void_p]
|
||||
|
@ -73,14 +73,14 @@ Device = HGLib_OpenDevice(DeviceNameList[0])
|
|||
|
||||
#设置扫描参数
|
||||
HGLib_SetDeviceParam = Objdll.HGLib_SetDeviceParam
|
||||
HGLib_SetDeviceParam.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p]
|
||||
HGLib_SetDeviceParam.argtypes = [ctypes.c_void_p, ctypes.c_uint, ctypes.c_void_p]
|
||||
HGLib_SetDeviceParam.restype = ctypes.c_int
|
||||
DevParam = ctypes.c_int(1) #HGLIB_OPTION_ENUMVALUE_DLSCLX_W -> 不进行多流输出类型
|
||||
Ret = HGLib_SetDeviceParam(Device, 1, byref(DevParam)) #见HGLib_SetDeviceParam 头文件接口说明 1 -> HGLIB_OPTION_NAME_DLSC 多流输出
|
||||
|
||||
bStop=False
|
||||
#扫描事件回调
|
||||
def HGLibDeviceScanEventFunc(device: c_void_p, event: c_ulong, err: c_int, info: c_char_p, param: c_void_p):
|
||||
def HGLibDeviceScanEventFunc(device: c_void_p, event: c_uint, err: c_int, info: c_char_p, param: c_void_p):
|
||||
print(info)
|
||||
if event == 2:#HGLIB_DEVSCAN_EVENT_END 扫描停止
|
||||
bStop=True
|
||||
|
@ -100,7 +100,7 @@ def HGLibDeviceScanImageFunc(device: c_void_p, image: c_void_p, param: c_void_p)
|
|||
return
|
||||
|
||||
#注册扫描相关事件并启动扫描
|
||||
FuncType1 = CFUNCTYPE(None, c_void_p, c_ulong, c_int, c_char_p, c_void_p)
|
||||
FuncType1 = CFUNCTYPE(None, c_void_p, c_uint, c_int, c_char_p, c_void_p)
|
||||
cb1 = FuncType1(HGLibDeviceScanEventFunc)
|
||||
FuncType2 = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p)
|
||||
cb2 = FuncType2(HGLibDeviceScanImageFunc)
|
||||
|
|
Loading…
Reference in New Issue