Home > other >  Python DLL call validate structure reference
Python DLL call validate structure reference

Time:09-24

C + + interfaces are defined as follows

ZHYLIB_API int ZHY_FV_Quality (const unsigned char * pImg, int nHeight, int nWidth, FV_QUARITY & amp; VQuarity);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Function: feature encoding, compression
Input parameters: the feature decoding feature
Output parameters: enfeat coding feature
Ensize coding feature size
Return values: 0 success
1 failure

Structures are defined as follows
Typedef struct _v_quarity {
Float fLeakThreshold;//the default value of 0.05, relaxed requirement optional 0.05 ~ 0.07, strict with optional 0.03 ~ 0.05
Float fPressThreshold;//the default value of 0.6, optional 0.62 relax requirements, strict with optional 0.58
Float fEnergyThreshold;//the default value of 0.095, unilateral equipment choose 0.08, top equipment choose 0.095, top shoot fingerprint refers to the vein to choose 0.085

Float fLeakRatio;//light-leaking coefficient, greater than fLeakThreshold light-leaking said image area is too large;
//quality evaluation is a light-leaking cases, this parameter by multiplexing transmission Fourier coefficient

Float fPress;//fingerprint coefficient, less than fPressThreshold said image contains a large number of fingerprint information
Float fImageEnergy;//image energy, less than fEnergyThreshold says more press
} FV_QUARITY;

Now I define this structure in python calls this DLL can be successful return value, but I need to take to DLL processing after FV_QUARITY & amp; VQuarity this structure the value of how to do,



Python implementation is as follows:

The import ctypes
The import cv2
The from ctypes import *
The import numpy as np

The class MyquarityStruct (Structure) :
_quarity_=[
(" fLeakThreshold c_float),
(" fPressThreshold c_float),
(" fEnergyThreshold c_float),
(" fLeakRatio c_float),
(" fPress c_float),
(" fImageEnergy c_float)
]

Mystr=MyquarityStruct ()


PDll=ctypes. WinDLL (r 'E: \ developer \ fukun_apitest - master \ fukun_apitest \ testcase \ zhy_fv401_x64 DLL')
Img=cv2. Imread (' E://VIS - 430102198206050000-1. BMP ')
# print (img)
#
Img=np. Asarray (img, dtype=np. Uint8)
Img2=img. Ctypes. Data_as (ctypes. C_char_p)
Iint=pDll. ZHY_FV_Init (0)
Print (" int return vaule is: ", iint)
# pDll. ZHY_FV_Quality. Restype=ctypes. C_int
# pDll. ZHY_FV_Quality. Argtypes=[byref (image_data), c_int, c_int, POINTER (MyquarityStruct)]
PDll. ZHY_FV_Quality. Restype=ctypes. POINTER (MyquarityStruct)
PDll. ZHY_FV_Quality (byref (img2), 320, 240, pointer (mystr))
Print (pDll. Magic __class__)
Print (mystr)



Can how to write c + + processing after the value in the structure of cellar









  • Related