face_engine

package module
v3.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 2 Imported by: 1

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)

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

func OnlineActivation

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

在线激活接口

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 //激活文件版本号
}

激活文件信息结构体

func GetActiveFileInfo

func GetActiveFileInfo() (ActiveFileInfo, error)

获取激活文件信息接口

type AgeInfo

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

年龄信息结构体

type EngineError added in v3.0.6

type EngineError struct {
	Code int
	Text string
}

SDK错误码

func (EngineError) Error added in v3.0.6

func (err EngineError) Error() string

实现Error接口

type Face3DAngle

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

人脸3D角度信息结构体

type FaceEngine

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

引擎结构体

func NewFaceEngine

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

创建一个新的引擎实例

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

func (*FaceEngine) Destroy

func (engine *FaceEngine) Destroy() error

销毁引擎

func (*FaceEngine) DetectFaces

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

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

func (*FaceEngine) FaceFeatureCompare

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

人脸特征比对

func (*FaceEngine) FaceFeatureExtract added in v3.0.5

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

单人脸特征提取

func (*FaceEngine) GetAge

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

获取年龄信息

func (*FaceEngine) GetFace3DAngle

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

获取3D角度信息

func (*FaceEngine) GetGender

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

获取性别信息

func (*FaceEngine) GetLivenessScore

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

获取RGB活体结果

func (*FaceEngine) GetLivenessScoreIR

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

获取IR活体结果

func (*FaceEngine) GetVersion

func (engine *FaceEngine) GetVersion() Version

获取版本信息

func (*FaceEngine) Process

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

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

func (*FaceEngine) ProcessIR

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

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

func (*FaceEngine) SetLivenessParam

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

设置活体置信度

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

type FaceFeature

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

人脸特征结构体

func (*FaceFeature) Release added in v3.0.5

func (feature *FaceFeature) Release()

释放内存

type GenderInfo

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

性别信息结构体

type LivenessInfo

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

活体信息

type LivenessThreshold

type LivenessThreshold struct {
	ThresholdModelBGR float32
	ThresholdModelIR  float32
}

活体置信度结构体

type MultiFaceInfo

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

多人脸信息结构体

type Rect

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

人脸坐标结构体

type SingleFaceInfo

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

单人脸信息结构体

func GetSingleFaceInfo added in v3.0.5

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

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

type Version

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

版本信息结构体

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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