arcface

package module
v3.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 9 Imported by: 0

README

虹软人脸检测SDK

LICENSE Supported platform Build Status GoDoc

基于虹软SDK V3

目前已适配的版本: v2.2.0 v3.0.0

开始使用

  • 安装方式一(不使用go mod):go get -d github.com/windosx/face-engine
  • 安装方式二(使用go mod):go get github.com/windosx/face-engine/v3
  • 编译:go build -o test github.com/windosx/face-engine/v3/cmd
  • 测试:./test
  • 库文件:Linux下将libarcsoft_face.so, libarcsoft_face_engine.so放入/usr/lib目录
  • Windows下将libarcsoft_face.dll, libarcsoft_face_engine.dll放入%WINDIR%/System32目录或执行文件同目录下
  • 编译环境依赖GCC Linux环境下编译需要先安装gcc,Windows下编译需要先安装MinGW-w64(32位下用mingw),并将libarcsoft_face.dll, libarcsoft_face_engine.dll放入MingGW-w64安装目录下的lib目录中

Documentation

Index

Constants

View Source
const (
	DetectModeVideo       = C.ASF_DETECT_MODE_VIDEO
	DetectModeImage       = C.ASF_DETECT_MODE_IMAGE
	OrientPriority0       = C.ASF_OP_0_ONLY
	OrientPriority90      = C.ASF_OP_90_ONLY
	OrientPriority270     = C.ASF_OP_270_ONLY
	OrientPriority180     = C.ASF_OP_180_ONLY
	OrientPriorityAllOut  = C.ASF_OP_ALL_OUT
	EnableNone            = C.ASF_NONE
	EnableFaceDetect      = C.ASF_FACE_DETECT
	EnableFaceRecognition = C.ASF_FACERECOGNITION
	EnableAge             = C.ASF_AGE
	EnableGender          = C.ASF_GENDER
	EnableFace3DAngle     = C.ASF_FACE3DANGLE
	EnableLiveness        = C.ASF_LIVENESS
	EnableIRLiveness      = C.ASF_IR_LIVENESS
	ColorFormatBGR24      = C.ASVL_PAF_RGB24_B8G8R8
	ColorFormatNV12       = C.ASVL_PAF_NV12
	ColorFormatNV21       = C.ASVL_PAF_NV21
	ColorFormatI420       = C.ASVL_PAF_I420
	ColorFormatYUYV       = C.ASVL_PAF_YUYV
)

Variables

This section is empty.

Functions

func Activation

func Activation(appId, sdkKey string) (err error)

Activation 在线激活接口,该接口与ASFOnlineActivation接口功能一致,推荐使用该接口

func DecodeImage

func DecodeImage(filePath string) (img image.Image, err error)

DecodeImage decode a image and retrun golang image interface

func GetImageHeight

func GetImageHeight(img image.Image) int

GetImageHeight 获取图片高度

func GetImageWidth

func GetImageWidth(img image.Image) int

GetImageWidth 获取图片宽度

func GetImageWidthAndHeight

func GetImageWidthAndHeight(filename string) (width, height int)

GetImageWidthAndHeight 获取图片宽高

func New3DSlice

func New3DSlice(x int, y int, z int) (theSlice [][][]uint8)

New3DSlice 创建矩阵

func NewRGBAMatrix

func NewRGBAMatrix(height int, width int) (rgbaMatrix [][][]uint8)

NewRGBAMatrix create a new rgba matrix

func OnlineActivation

func OnlineActivation(appId, sdkKey string) (err error)

OnlineActivation 在线激活接口

func Resize

func Resize(src *image.NRGBA, width int, height int) *image.NRGBA

Resize 缩放图片

func ResizeForMatrix

func ResizeForMatrix(img image.Image, width int, height int) (imgMatrix [][][]uint8, err error)

ResizeForMatrix 缩放图片

Types

type ActiveFileInfo

type ActiveFileInfo struct {
	StartTime   string //开始时间
	EndTime     string //截止时间
	Platform    string //平台
	SdkType     string //sdk类型
	AppId       string //APPID
	SdkKey      string //SDKKEY
	SdkVersion  string //SDK版本号
	FileVersion string //激活文件版本号
}

ActiveFileInfo 激活文件信息结构体

func GetActiveFileInfo

func GetActiveFileInfo() (ActiveFileInfo, error)

GetActiveFileInfo 获取激活文件信息接口

type AgeInfo

type AgeInfo struct {
	AgeArray []int32 // "0" 代表不确定,大于0的数值代表检测出来的年龄结果
	Num      int32   // 检测的人脸个数
}

AgeInfo 年龄信息结构体

type EngineError

type EngineError struct {
	Code int
	Text string
}

EngineError SDK错误码

func (EngineError) Error

func (err EngineError) Error() string

实现Error接口

type Face3DAngle

type Face3DAngle struct {
	Roll   []float32
	Yaw    []float32
	Pitch  []float32
	Status []int32 // 0: 正常,其他数值:出错
	Num    int32
}

Face3DAngle 人脸3D角度信息结构体

type FaceEngine

type FaceEngine struct {
	// contains filtered or unexported fields
}

FaceEngine 引擎结构体

func NewFaceEngine

func NewFaceEngine(dm, op uint32, faceScale, maxFaceNum, combinedMask C.MInt32) (*FaceEngine, error)

NewFaceEngine 创建一个新的引擎实例

如果调用初始化函数失败则返回一个错误

func (*FaceEngine) Destroy

func (engine *FaceEngine) Destroy() error

Destroy 销毁引擎

func (*FaceEngine) DetectFaces

func (engine *FaceEngine) DetectFaces(width, height int, format C.MInt32, imgData []byte) (faceInfo MultiFaceInfo, err error)

DetectFaces 人脸检测,目前不支持IR图像数据检测

func (*FaceEngine) DetectFacesEx

func (engine *FaceEngine) DetectFacesEx(imageData ImageData) (faceInfo MultiFaceInfo, err error)

DetectFacesEx 检测人脸信息

该接口与 DetectFaces 功能一致,但采用结构体的形式传入图像数据,对更高精度的图像兼容性更好。

func (*FaceEngine) FaceFeatureCompare

func (engine *FaceEngine) FaceFeatureCompare(feature1, feature2 FaceFeature) (float32, error)

FaceFeatureCompare 人脸特征比对

func (*FaceEngine) FaceFeatureExtract

func (engine *FaceEngine) FaceFeatureExtract(width, height int, format C.MInt32, imgData []byte, faceInfo SingleFaceInfo) (faceFeature FaceFeature, err error)

FaceFeatureExtract 单人脸特征提取

func (*FaceEngine) FaceFeatureExtractEx

func (engine *FaceEngine) FaceFeatureExtractEx(
	imageData ImageData,
	faceInfo SingleFaceInfo,
) (feature FaceFeature, err error)

FaceFeatureExtractEx 单人脸特征提取

该接口与 ASFFaceFeatureExtract 功能一致,但采用结构体的形式传入图像数据,对更高精度的图像兼容性更好

func (*FaceEngine) GetAge

func (engine *FaceEngine) GetAge() (AgeInfo, error)

GetAge 获取年龄信息

func (*FaceEngine) GetFace3DAngle

func (engine *FaceEngine) GetFace3DAngle() (Face3DAngle, error)

GetFace3DAngle 获取3D角度信息

func (*FaceEngine) GetGender

func (engine *FaceEngine) GetGender() (GenderInfo, error)

GetGender 获取性别信息

func (*FaceEngine) GetLivenessScore

func (engine *FaceEngine) GetLivenessScore() (LivenessInfo, error)

GetLivenessScore 获取RGB活体结果

func (*FaceEngine) GetLivenessScoreIR

func (engine *FaceEngine) GetLivenessScoreIR() (LivenessInfo, error)

GetLivenessScoreIR 获取IR活体结果

func (*FaceEngine) GetVersion

func (engine *FaceEngine) GetVersion() Version

GetVersion 获取版本信息

func (*FaceEngine) Process

func (engine *FaceEngine) Process(width, height int, format C.MInt32, imgData []byte, detectedFaces MultiFaceInfo, combinedMask C.MInt32) error

Process 年龄/性别/人脸3D角度(该接口仅支持RGB图像),最多支持4张人脸信息检测,超过部分返回未知 RGB活体仅支持单人脸检测,该接口不支持检测IR活体

func (*FaceEngine) ProcessEx

func (engine *FaceEngine) ProcessEx(imageData ImageData, faceInfo MultiFaceInfo, combinedMask C.MInt32) error

ProcessEx 人脸信息检测(年龄/性别/人脸3D角度),最多支持4张人脸信息检测,超过部分返回未知(活体仅支持单张人脸检测,超出返回未知),接口仅支持可见光图像检测

该接口与 Process 功能一致,但采用结构体的形式传入图像数据,对更高精度的图像兼容性更好

func (*FaceEngine) ProcessIR

func (engine *FaceEngine) ProcessIR(width, height int, format C.MInt32, imgData []byte, detectedFaces MultiFaceInfo, combinedMask C.MInt32) error

ProcessIR 该接口目前仅支持单人脸IR活体检测(不支持年龄、性别、3D角度的检测),默认取第一张人脸

func (*FaceEngine) SetLivenessParam

func (engine *FaceEngine) SetLivenessParam(threshold LivenessThreshold) error

SetLivenessParam 设置活体置信度

取值范围[0-1]内部默认数值RGB-0.75,IR-0.7, 用户可以根据实际需求,设置不同的阈值

type FaceFeature

type FaceFeature struct {
	Feature     []byte // 人脸特征信息
	FeatureSize int32  // 人脸特征信息长度
	// contains filtered or unexported fields
}

FaceFeature 人脸特征结构体

func ReadFaceFeatureFromBytes

func ReadFaceFeatureFromBytes(bytes []byte) (feature FaceFeature)

ReadFaceFeatureFromBytes 将字节数据转为人脸特征数据

func (*FaceFeature) Release

func (feature *FaceFeature) Release()

Release 释放内存

type GenderInfo

type GenderInfo struct {
	GenderArray []int32 // "0" 表示 男性, "1" 表示 女性, "-1" 表示不确定
	Num         int32   // 检测的人脸个数
}

GenderInfo 性别信息结构体

type ImageData

type ImageData struct {
	PixelArrayFormat C.MUInt32
	Width            int
	Height           int
	ImageData        [4][]uint8
	WidthStep        [4]int
}

ImageData 对应ASVLOFFSCREEN结构体

type ImageInfo

type ImageInfo struct {
	DataUInt8 []uint8
	Width     int
	Height    int
}

ImageInfo 包含图片数据和宽高信息的结构体

func GetResizedImageInfo

func GetResizedImageInfo(img image.Image) (imageInfo ImageInfo)

GetResizedImageInfo 获取适配SDK大小的图片,并转为BGR格式的数据

type LivenessInfo

type LivenessInfo struct {
	IsLive []int32 // 0:非真人 1:真人 -1:不确定 -2:传入人脸数>1
	Num    int32
}

LivenessInfo 活体信息

type LivenessThreshold

type LivenessThreshold struct {
	ThresholdModelBGR float32
	ThresholdModelIR  float32
}

LivenessThreshold 活体置信度结构体

type MultiFaceInfo

type MultiFaceInfo struct {
	FaceRect   []Rect  // 人脸框信息
	FaceOrient []int32 // 输入图像的角度
	FaceNum    int32   // 检测到的人脸个数
	FaceID     []int32 // face ID,IMAGE模式下不返回FaceID
	// contains filtered or unexported fields
}

MultiFaceInfo 多人脸信息结构体

type Rect

type Rect struct {
	Left   int32
	Top    int32
	Right  int32
	Bottom int32
}

Rect 人脸坐标结构体

type SingleFaceInfo

type SingleFaceInfo struct {
	FaceRect   Rect  // 人脸框信息
	FaceOrient int32 // 输入图像的角度,可以参考 ArcFaceCompare_OrientCode
}

SingleFaceInfo 单人脸信息结构体

func GetSingleFaceInfo

func GetSingleFaceInfo(multiFaceInfo MultiFaceInfo) (faceInfo []SingleFaceInfo)

GetSingleFaceInfo 从多人脸结构体中提取单人脸信息

type Version

type Version struct {
	Version   string // 版本号
	BuildDate string // 构建日期
	CopyRight string // Copyright
}

Version 版本信息结构体

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL