从我之前的问题继续,我已经尝试了ctypes,struct和nametuple,但仍然无法获取数据。如果我将此dll文件导入到我的C ++程序中,我设法使其正常工作。有人可以为此提供帮助,这将真的很有帮助。非常感谢你!
c ++代码
printf("Number: %s\n", NET_DVR_PLATE_INFO().sLicense);
c代码
typedef struct tagNET_DVR_PLATE_INFO
{
BYTE byPlateType;
BYTE byColor;
BYTE byBright;
BYTE byLicenseLen;
BYTE byEntireBelieve;
BYTE byRegion;
BYTE byCountry;
BYTE byArea;
BYTE byPlateSize;
BYTE byRes[15];
char sPlateCategory[MAX_CATEGORY_LEN/*8*/];
DWORD dwXmlLen;
char* pXmlBuf;
NET_VCA_RECT struPlateRect;
char sLicense[MAX_LICENSE_LEN];
BYTE byBelieve[MAX_LICENSE_LEN];
}NET_DVR_PLATE_INFO, *LPNET_DVR_PLATE_INFO;
python代码
hcnetsdk = ctypes.windll.LoadLibrary(".\\HCNetSDK.dll")
class NET_DVR_PLATE_INFO(ctypes.Structure):
_fields_ = [
("byPlateType", ctypes.c_byte),
("byColor", ctypes.c_byte),
("byBright", ctypes.c_byte),
("byLicenseLen", ctypes.c_byte),
("byEntireBelieve", ctypes.c_byte), #
("byRegion", ctypes.c_byte),
("byCountry", ctypes.c_byte),
("byArea", ctypes.c_byte),
("byPlateSize", ctypes.c_byte),
("byRes", ctypes.c_byte * 15),
("sPlateCategory", ctypes.c_char * 8),
("dwXmlLen", ctypes.c_short),
("pXmlBuf", ctypes.c_char),
("sLicense", ctypes.c_char * 16),
("byBelieve", ctypes.c_byte * 16)]
def getPlateNumber():
platenumber= NET_DVR_PLATE_INFO()
y = hcnetsdk.platenumber.sLicense
print(y)
我会接到错误电话
AttributeError: function 'platenumber' not found