baidu

package
v0.0.0-...-5bb0c7b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Baidu

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

func NewBaidu

func NewBaidu(cah cache.Cache, config *config.Config, logFunc func(string)) *Baidu

func (*Baidu) AuditImage

func (bd *Baidu) AuditImage(data []byte, appId, appSecret string) (*BaiduAuditResult, error)

func (*Baidu) AuditText

func (bd *Baidu) AuditText(str string, appId, appSecret string) (*BaiduAuditResult, error)

func (*Baidu) Exit

func (bd *Baidu) Exit() error

func (*Baidu) FaceMultiSearch

func (bd *Baidu) FaceMultiSearch(
	userGroupIdList []string,
	imageData []byte,
	qualityControl FaceControlLevel,
	livenessControl FaceControlLevel,
	appId, appSecret string) (*FaceMultiSearchResponse, error)

func (*Baidu) FaceSearch

func (bd *Baidu) FaceSearch(
	userGroupIdList []string,
	imageData []byte,
	qualityControl FaceControlLevel,
	livenessControl FaceControlLevel,
	appId, appSecret string) (*FaceSearchResponse, error)

func (*Baidu) FaceSetUserAdd

func (bd *Baidu) FaceSetUserAdd(
	userGroupId, userId string,
	userInfo string,
	imageData []byte,
	appId, appSecret string) (*FaceSetUserAddResponse, error)

func (*Baidu) GetAccessTokenBceByClient

func (bd *Baidu) GetAccessTokenBceByClient(apiKey, secretKey string) (token *BaiduToken, err error)

func (*Baidu) GetAccessTokenOpenApiByClient

func (bd *Baidu) GetAccessTokenOpenApiByClient(apiKey, secretKey string) (token *BaiduToken, err error)

func (*Baidu) IdCardRecognize

func (bd *Baidu) IdCardRecognize(
	imageData []byte,
	side IdCardSide,
	detectRisk bool,
	appId, appSecret string) (*IdCardRecognizeResponse, error)

func (*Baidu) PersonVerify

func (bd *Baidu) PersonVerify(
	imageData []byte,
	fullName string,
	idCardNo string,
	qualityControl FaceControlLevel,
	livenessControl FaceControlLevel,
	appId, appSecret string) (*PersonVerifyResponse, error)

func (*Baidu) VoiceRecognizePro

func (bd *Baidu) VoiceRecognizePro(
	voiceData []byte,
	appId, appSecret string) (*VoiceRecognizeResponse, error)

type BaiduAuditResult

type BaiduAuditResult struct {
	ErrorCode      int    `json:"error_code" xml:"error_code"`
	ErrorMsg       string `json:"error_msg" xml:"error_msg"`
	LogID          int64  `json:"log_id" xml:"log_id"`
	Conclusion     string `json:"conclusion" xml:"conclusion"`
	ConclusionType int    `json:"conclusionType" xml:"conclusionType"`
	Data           []struct {
		ConclusionType int      `json:"conclusionType,omitempty" xml:"conclusionType,omitempty"`
		Msg            string   `json:"msg" xml:"msg"`
		DatasetName    string   `json:"datasetName,omitempty" xml:"datasetName,omitempty"`
		Type           int      `json:"type" xml:"type"`
		SubType        int      `json:"subType" xml:"subType"`
		Conclusion     string   `json:"conclusion,omitempty" xml:"conclusion,omitempty"`
		Probability    float64  `json:"probability,omitempty" xml:"probability,omitempty"`
		Codes          []string `json:"codes,omitempty" xml:"codes,omitempty"`
		Stars          []struct {
			Probability float64 `json:"probability" xml:"probability"`
			Name        string  `json:"name" xml:"name"`
		} `json:"stars,omitempty" xml:"stars,omitempty"`
		Completeness float64 `json:"completeness,omitempty" xml:"completeness,omitempty"`
		Hits         []struct {
			Probability int      `json:"probability" xml:"probability"`
			DatasetName string   `json:"datasetName" xml:"datasetName"`
			Words       []string `json:"words" xml:"words"`
		} `json:"hits,omitempty" xml:"hits,omitempty"`
		Conclution     string `json:"conclution,omitempty" xml:"conclution,omitempty"`
		ConclutionType int    `json:"conclutionType,omitempty" xml:"conclutionType,omitempty"`
	} `json:"data" xml:"data"`
	RawData []struct {
		Type    int `json:"type" xml:"type"`
		Results []struct {
			Result []struct {
				Location struct {
					Top    int `json:"top" xml:"top"`
					Left   int `json:"left" xml:"left"`
					Width  int `json:"width" xml:"width"`
					Height int `json:"height" xml:"height"`
				} `json:"location" xml:"location"`
				Stars []struct {
					Probability float64 `json:"probability" xml:"probability"`
					Name        string  `json:"name" xml:"name"`
				} `json:"stars" xml:"stars"`
			} `json:"result" xml:"result"`
			LogID             int64  `json:"log_id" xml:"log_id"`
			IncludePolitician string `json:"include_politician" xml:"include_politician"`
			ResultNum         int    `json:"result_num" xml:"result_num"`
			ResultConfidence  string `json:"result_confidence" xml:"result_confidence"`
		} `json:"results" xml:"results"`
	} `json:"rawData" xml:"rawData"`
}

type BaiduToken

type BaiduToken struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
	RefreshToken     string `json:"refresh_token" xml:"refresh_token"`
	ExpiresIn        int64  `json:"expires_in" xml:"expires_in"`
	ExpiresAt        int64  `json:"expires_at" xml:"expires_at"`
	SessionKey       string `json:"session_key" xml:"session_key"`
	AccessToken      string `json:"access_token" xml:"access_token"`
	Scope            string `json:"scope" xml:"scope"`
	SessionSecret    string `json:"session_secret" xml:"session_secret"`
}

type FaceControlLevel

type FaceControlLevel string
const (
	FaceControlLevel_None   FaceControlLevel = "NONE"
	FaceControlLevel_Low    FaceControlLevel = "LOW"
	FaceControlLevel_Normal FaceControlLevel = "NORMAL"
	FaceControlLevel_High   FaceControlLevel = "HIGH"
)

type FaceMultiSearchRequest

type FaceMultiSearchRequest struct {
	Image           string `json:"image,omitempty"`
	ImageType       string `json:"image_type,omitempty"`
	GroupIDList     string `json:"group_id_list,omitempty"`
	MaxFaceNum      int    `json:"max_face_num,omitempty"`
	MatchThreshold  int    `json:"match_threshold,omitempty"`
	MaxUserNum      int    `json:"max_user_num,omitempty"`
	QualityControl  string `json:"quality_control,omitempty"`
	LivenessControl string `json:"liveness_control,omitempty"`
}

type FaceMultiSearchResponse

type FaceMultiSearchResponse struct {
	ErrorCode int    `json:"error_code"`
	ErrorMsg  string `json:"error_msg"`
	LogID     uint64 `json:"log_id"`
	Timestamp int    `json:"timestamp"`
	Cached    int    `json:"cached"`
	Result    struct {
		FaceNum  int `json:"face_num"`
		FaceList []struct {
			FaceToken string `json:"face_token"`
			Location  struct {
				Left     float64 `json:"left"`
				Top      float64 `json:"top"`
				Width    int     `json:"width"`
				Height   int     `json:"height"`
				Rotation int     `json:"rotation"`
			} `json:"location"`
			UserList []struct {
				GroupID  string  `json:"group_id"`
				UserID   string  `json:"user_id"`
				UserInfo string  `json:"user_info"`
				Score    float64 `json:"score"`
			} `json:"user_list"`
		} `json:"face_list"`
	} `json:"result"`
}

type FaceSearchRequest

type FaceSearchRequest struct {
	Image           string `json:"image,omitempty"`
	ImageType       string `json:"image_type,omitempty"`
	GroupIDList     string `json:"group_id_list,omitempty"`
	QualityControl  string `json:"quality_control,omitempty"`
	LivenessControl string `json:"liveness_control,omitempty"`
	// 当需要对特定用户进行比对时,指定user_id进行比对。即人脸认证功能。
	UserId       string `json:"user_id,omitempty"`
	MaxUserNum   uint32 `json:"max_user_num,omitempty"`
	FaceSortType int    `json:"face_sort_type,omitempty"`
}

type FaceSearchResponse

type FaceSearchResponse struct {
	ErrorCode int    `json:"error_code" xml:"error_code"`
	ErrorMsg  string `json:"error_msg" xml:"error_msg"`
	LogID     uint64 `json:"log_id"`
	FaceToken string `json:"face_token"`
	UserList  []struct {
		GroupID  string  `json:"group_id"`
		UserID   string  `json:"user_id"`
		UserInfo string  `json:"user_info"`
		Score    float64 `json:"score"`
	} `json:"user_list"`
}

type FaceSetUserAddRequest

type FaceSetUserAddRequest struct {
	Image           string `json:"image,omitempty"`
	ImageType       string `json:"image_type,omitempty"`
	GroupID         string `json:"group_id,omitempty"`
	UserID          string `json:"user_id,omitempty"`
	UserInfo        string `json:"user_info,omitempty"`
	QualityControl  string `json:"quality_control,omitempty"`
	LivenessControl string `json:"liveness_control,omitempty"`
}

type FaceSetUserAddResponse

type FaceSetUserAddResponse struct {
	ErrorCode int    `json:"error_code" xml:"error_code"`
	ErrorMsg  string `json:"error_msg" xml:"error_msg"`
	LogID     uint64 `json:"log_id"`
	FaceToken string `json:"face_token"`
	Location  struct {
		Left     int `json:"left"`
		Top      int `json:"top"`
		Width    int `json:"width"`
		Height   int `json:"height"`
		Rotation int `json:"rotation"`
	} `json:"location"`
}

type IdCardRecognizeRequest

type IdCardRecognizeRequest struct {
	Image string `json:"image"`
	Side  string `json:"side"`
}

type IdCardRecognizeResponse

type IdCardRecognizeResponse struct {
	LogID         int64  `json:"log_id"`
	Direction     int    `json:"direction"`
	ImageStatus   string `json:"image_status"`
	Photo         string `json:"photo"`
	PhotoLocation struct {
		Width  int `json:"width"`
		Top    int `json:"top"`
		Left   int `json:"left"`
		Height int `json:"height"`
	} `json:"photo_location"`
	WordsResult struct {
		Address struct {
			Location struct {
				Left   int `json:"left"`
				Top    int `json:"top"`
				Width  int `json:"width"`
				Height int `json:"height"`
			} `json:"location"`
			Words string `json:"words"`
		} `json:"住址"`
		IdCard struct {
			Location struct {
				Left   int `json:"left"`
				Top    int `json:"top"`
				Width  int `json:"width"`
				Height int `json:"height"`
			} `json:"location"`
			Words string `json:"words"`
		} `json:"公民身份号码"`
		Birth struct {
			Location struct {
				Left   int `json:"left"`
				Top    int `json:"top"`
				Width  int `json:"width"`
				Height int `json:"height"`
			} `json:"location"`
			Words string `json:"words"`
		} `json:"出生"`
		Name struct {
			Location struct {
				Left   int `json:"left"`
				Top    int `json:"top"`
				Width  int `json:"width"`
				Height int `json:"height"`
			} `json:"location"`
			Words string `json:"words"`
		} `json:"姓名"`
		Sex struct {
			Location struct {
				Left   int `json:"left"`
				Top    int `json:"top"`
				Width  int `json:"width"`
				Height int `json:"height"`
			} `json:"location"`
			Words string `json:"words"`
		} `json:"性别"`
		Nationality struct {
			Location struct {
				Left   int `json:"left"`
				Top    int `json:"top"`
				Width  int `json:"width"`
				Height int `json:"height"`
			} `json:"location"`
			Words string `json:"words"`
		} `json:"民族"`
	} `json:"words_result"`
	WordsResultNum int `json:"words_result_num"`
}

type IdCardSide

type IdCardSide string
const (
	IdCardSide_Front IdCardSide = "front"
	IdCardSide_Back  IdCardSide = "back"
)

type PersonVerifyRequest

type PersonVerifyRequest struct {
	Image           string `json:"image"`
	ImageType       string `json:"image_type"`
	IDCardNumber    string `json:"id_card_number"`
	Name            string `json:"name"`
	QualityControl  string `json:"quality_control"`
	LivenessControl string `json:"liveness_control"`
}

type PersonVerifyResponse

type PersonVerifyResponse struct {
	ErrorCode int    `json:"error_code"`
	ErrorMsg  string `json:"error_msg"`
	LogID     int    `json:"log_id"`
	Timestamp int    `json:"timestamp"`
	Cached    int    `json:"cached"`
	Result    struct {
		Score float64 `json:"score"`
	} `json:"result"`
}

type VoiceRecognizeResponse

type VoiceRecognizeResponse struct {
	CorpusNo string   `json:"corpus_no"`
	ErrMsg   string   `json:"err_msg"`
	ErrNo    int      `json:"err_no"`
	Result   []string `json:"result"`
	Sn       string   `json:"sn"`
}

Jump to

Keyboard shortcuts

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