欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

python如何調(diào)用虹軟2.0第三版-創(chuàng)新互聯(lián)

小編給大家分享一下python如何調(diào)用虹軟2.0第三版,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

吉安ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

這一版,對(duì)虹軟的功能進(jìn)行了一些封裝,添加了人臉特征比對(duì),比對(duì)結(jié)果保存到文件,和從文件提取特征進(jìn)行比對(duì),大體功能基本都已經(jīng)實(shí)現(xiàn),可以進(jìn)行下一步的應(yīng)用開發(fā)了

face_class.py

from ctypes import *
#人臉框
class MRECT(Structure):
  _fields_=[(u'left1',c_int32),(u'top1',c_int32),(u'right1',c_int32),(u'bottom1',c_int32)]
#版本信息   版本號(hào),構(gòu)建日期,版權(quán)說明
class ASF_VERSION(Structure):
  _fields_=[('Version',c_char_p),('BuildDate',c_char_p),('CopyRight',c_char_p)]
#單人人臉信息 人臉狂,人臉角度
class ASF_SingleFaceInfo(Structure):
  _fields_=[('faceRect',MRECT),('faceOrient',c_int32)]
#多人人臉信息 人臉框數(shù)組,人臉角度數(shù)組,人臉數(shù)
class ASF_MultiFaceInfo(Structure):
  # _fields_=[('faceRect',POINTER(MRECT)),('faceOrient',POINTER( c_int32)),('faceNum',c_int32)]
  _fields_=[(u'faceRect',POINTER(MRECT)),(u'faceOrient',POINTER(c_int32)),(u'faceNum', c_int32)]
  # _fields_=[(u'faceRect',MRECT*50),(u'faceOrient',c_int32*50),(u'faceNum',c_int32)]
#人臉特征 人臉特征,人臉特征長(zhǎng)度
class ASF_FaceFeature(Structure):
  _fields_=[('feature',c_void_p),('featureSize',c_int32)]
#自定義圖片類
class IM:
  def __init__(self):
    self.filepath=None
    self.date=None
    self.width=0
    self.height=0

face_dll.py

from ctypes import *
from face_class import *
wuyongdll=CDLL('d:\python\Test\Face\lib\X64\libarcsoft_face.dll')
dll=CDLL('d:\python\Test\Face\lib\X64\libarcsoft_face_engine.dll')
dllc=cdll.msvcrt
ASF_DETECT_MODE_VIDEO = 0x00000000
ASF_DETECT_MODE_IMAGE = 0xFFFFFFFF
c_ubyte_p = POINTER(c_ubyte) 
#激活
jihuo=dll.ASFActivation
jihuo.restype = c_int32
jihuo.argtypes = (c_char_p,c_char_p)
#初始化
chushihua=dll.ASFInitEngine
chushihua.restype=c_int32
chushihua.argtypes=(c_long,c_int32,c_int32,c_int32,c_int32,POINTER(c_void_p))
#人臉識(shí)別
shibie=dll.ASFDetectFaces
shibie.restype=c_int32
shibie.argtypes=(c_void_p,c_int32,c_int32,c_int32,POINTER(c_ubyte),POINTER(ASF_MultiFaceInfo))
#特征提取
tezheng=dll.ASFFaceFeatureExtract
tezheng.restype=c_int32
tezheng.argtypes=(c_void_p,c_int32,c_int32,c_int32,POINTER(c_ubyte),POINTER(ASF_SingleFaceInfo),POINTER(ASF_FaceFeature))

#特征比對(duì)
bidui=dll.ASFFaceFeatureCompare
bidui.restype=c_int32
bidui.argtypes=(c_void_p,POINTER(ASF_FaceFeature),POINTER(ASF_FaceFeature),POINTER(c_float))
malloc = dllc.malloc
free = dllc.free
memcpy = dllc.memcpy

malloc.restype = c_void_p
malloc.argtypes = (c_size_t, )
free.restype = None
free.argtypes = (c_void_p, )
memcpy.restype = c_void_p
memcpy.argtypes = (c_void_p, c_void_p, c_size_t)

face_function.py

import face_dll,face_class
from ctypes import *
import cv2
from io import BytesIO
# from Main import *
Handle=c_void_p()
c_ubyte_p = POINTER(c_ubyte) 
# 激活函數(shù)
def JH(appkey,sdkey):
  ret=face_dll.jihuo(appkey,sdkey)
  return ret
# 初始化函數(shù)
def CSH():# 1:視頻或圖片模式,2角度,3最小人臉尺寸推薦16,4最多人臉數(shù)大50,5功能,6返回激活句柄
  ret=face_dll.chushihua(0xFFFFFFFF,0x1,16,50,5,byref(Handle))
  # Main.Handle=Handle
  return ret,Handle
# cv2記載圖片并處理
def LoadImg(im):
  img=cv2.imread(im.filepath)
  sp=img.shape
  img=cv2.resize(img,(sp[1]//4*4,sp[0]//4*4))
  sp=img.shape
  im.data=img
  im.width=sp[1]
  im.height=sp[0]
  return im
def RLSB(im):
  faces=face_class.ASF_MultiFaceInfo()
  img=im.data
  imgby=bytes(im.data)
  imgcuby=cast(imgby,c_ubyte_p)
  ret=face_dll.shibie(Handle,im.width,im.height,0x201,imgcuby,byref(faces))
  return ret,faces
# 顯示人臉識(shí)別圖片
def showimg(im,faces):
  for i in range(0,faces.faceNum):
    ra=faces.faceRect[i]
    cv2.rectangle(im.data,(ra.left1,ra.top1),(ra.right1,ra.bottom1),(255,0,0,),2)
  cv2.imshow('faces',im.data)
  cv2.waitKey(0)
#提取人臉特征
def RLTZ(im,ft):
  detectedFaces=face_class.ASF_FaceFeature()
  img=im.data
  imgby=bytes(im.data)
  imgcuby=cast(imgby,c_ubyte_p)
  ret=face_dll.tezheng(Handle,im.width,im.height,0x201,imgcuby,ft,byref(detectedFaces))
  if ret==0:
    retz=face_class.ASF_FaceFeature()
    retz.featureSize=detectedFaces.featureSize
    #必須操作內(nèi)存來保留特征值,因?yàn)閏++會(huì)在過程結(jié)束后自動(dòng)釋放內(nèi)存
    retz.feature=face_dll.malloc(detectedFaces.featureSize)
    face_dll.memcpy(retz.feature,detectedFaces.feature,detectedFaces.featureSize)
    # print('提取特征成功:',detectedFaces.featureSize,mem)
    return ret,retz
  else:
    return ret
#特征值比對(duì),返回比對(duì)結(jié)果
def BD(tz1,tz2):
  jg=c_float()
  ret=face_dll.bidui(Handle,tz1,tz2,byref(jg))
  return ret,jg.value
#單人特征寫入文件
def writeFTFile(feature,filepath):
  f = BytesIO(string_at(feature.feature,feature.featureSize))
  a=open(filepath,'wb')
  a.write(f.getvalue())
  a.close()
#從多人中提取單人數(shù)據(jù)
def getsingleface(singleface,index):
  ft=face_class.ASF_SingleFaceInfo()
  ra=singleface.faceRect[index]
  ft.faceRect.left1=ra.left1
  ft.faceRect.right1=ra.right1
  ft.faceRect.top1=ra.top1
  ft.faceRect.bottom1=ra.bottom1
  ft.faceOrient=singleface.faceOrient[index]
  return ft
#從文件獲取特征值
def ftfromfile(filepath):
  fas=face_class.ASF_FaceFeature()
  f=open('d:/1.dat','rb')
  b=f.read()
  f.close()
  fas.featureSize=b.__len__()
  fas.feature=face_dll.malloc(fas.featureSize)
  face_dll.memcpy(fas.feature,b,fas.featureSize)
  return fas

Main1.py

import face_dll,face_class
from ctypes import *
import cv2
import face_function as fun
Appkey=b''
SDKey=b''
# 激活
ret=fun.JH(Appkey,SDKey)
if ret==0 or ret==90114:
  print('激活成功:',ret)
else:
  print('激活失敗:',ret)
  pass
# 初始化
ret=fun.CSH()
if ret[0]==0:
  print('初始化成功:',ret,'句柄',fun.Handle)
else:
  print('初始化失敗:',ret)
# 加載圖片
im=face_class.IM()
im.filepath='e:/2.jpg'
im=fun.LoadImg(im)
print(im.filepath,im.width,im.height)
# cv2.imshow('im',im.data)
# cv2.waitKey(0)
print('加載圖片完成:',im)

ret=fun.RLSB(im)
if ret[0]==-1:
  print('人臉識(shí)別失敗:',ret)
  pass
else:
  print('人臉識(shí)別成功:',ret)
# 顯示人臉照片
# showimg(im,ret)
#提取單人1特征
ft=fun.getsingleface(ret[1],0)
tz1=fun.RLTZ(im,ft)[1]
#提取單人2特征
ft=fun.getsingleface(ret[1],1)
tz2=fun.RLTZ(im,ft)[1]
#特征保存到文件
# fun.writeFTFile(tz1,'d:/1.dat')
# fun.writeFTFile(tz2,'d:/2.dat')
#文件獲取特征
tz=fun.ftfromfile('d:/1.dat')
jg=fun.BD(tz1,tz)
print(jg[1])
#結(jié)果比對(duì)
# jg=fun.BD(tz1,tz2)
# print(jg[1])

看完了這篇文章,相信你對(duì)“python如何調(diào)用虹軟2.0第三版”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道,感謝各位的閱讀!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁名稱:python如何調(diào)用虹軟2.0第三版-創(chuàng)新互聯(lián)
文章位置:http://aaarwkj.com/article34/dopppe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、虛擬主機(jī)、外貿(mào)網(wǎng)站建設(shè)、ChatGPT、面包屑導(dǎo)航、營(yíng)銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)
亚洲综合色婷婷在线影院| 在线观看国产小视频不卡| 国产一区二区不卡在线播放| 国产成人精品手机在线观看| 女同三人按摩高潮喷出| 精品人妻中文字幕在线| 性激烈的欧美三级男同| 亚洲精品在线观看第一页| 日本精品一区二区三区免费| 国产不卡一区不卡二区| 四影虎影永久免费观看 | 日韩欧美短视频在线观看| 最新日韩人妻中文字幕一区| 国产午夜在线观看免费视频| 久久精品国产av极品| 久久se精品人妻一区二区三区| 亚洲午夜福利啪啪啪| 国产精品中文第一字幕| 校园春色亚洲欧美日韩| 男人天堂插插综合搜索| 亚洲成人国产一区二区| 无遮挡无掩盖的免费网站| 人人妻人人澡人人爽老妇| 欧洲一区二区在线激情| 日本不卡二区高清三区| 在线国产精品中文字幕| 水牛av影视亚洲精品| 亚洲精品一区二区三区不卡| av毛片天堂在线观看| 人妻艳情一区二区三区| 久草视频免费福利资源站| 尤物在线免费观看视频| 亚洲精品成人久久av| 欧美一区二区三区顶级黄片| 色哟哟亚洲精品一区二区| 日韩在线免费色视频| 亚洲国产精品午夜福利在线播放 | 丰满人妻被黑人猛烈进入| 国产免费av剧情演绎| 国产极品嫩模在线观看91| 成人性生活三级黄色片|