C++ 介面定義如下
ZHYLIB_API int ZHY_FV_Quality(const unsigned char *pImg, int nHeight,int nWidth, FV_QUARITY &vQuarity);
/****************************************
函式功能:特征編碼,壓縮
輸入引數:feature 解碼特征
輸出引數:enfeat 編碼特征
ensize 編碼特征大小
回傳值 :0 成功
-1 失敗
結構體定義如下
typedef struct _v_quarity{
float fLeakThreshold; //默認值0.05,放松要求可選0.05~0.07,嚴格要求可選0.03~0.05
float fPressThreshold; //默認值0.6,放松要求可選0.62,嚴格要求可選0.58
float fEnergyThreshold; //默認值0.095,單側設備選0.08,頂射設備選0.095,頂射指紋指靜脈選0.085
float fLeakRatio; // 漏光系數,大于 fLeakThreshold 表示影像漏光區域過大;
//質量評估為非漏光情況下,本引數被復用傳遞傅里葉系數
float fPress; // 指紋系數,小于 fPressThreshold 表示影像中含大量指紋資訊
float fImageEnergy; // 影像能量,小于 fEnergyThreshold 表示有按壓
}FV_QUARITY;
現在我用python 定義這個結構體呼叫這個DLL 可以成功得到反回值,但是我需要取到DLL 處理過后的 FV_QUARITY &vQuarity 這個結構體的值怎么辦啊。
python實作如下:
import ctypes
import cv2
from ctypes import *
import numpy as np
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.__class__)
print(mystr)
要怎么寫才能取到C++ 處理過后的結構體里的值啊 求教
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/72001.html
上一篇:vscode無法呼叫圖片
下一篇:Python3中使用db.session.add()與db.session.commit()無法向MySQL中增加資料,代碼也不報錯,各位大佬求教!
