kit

package module
v0.0.0-...-271ea0a Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2018 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go kit

Documentation

Index

Examples

Constants

View Source
const (
	// FacePrefix 脸前缀
	FacePrefix byte = 'F'
)

Variables

This section is empty.

Functions

func CmdBool

func CmdBool(cmd *cobra.Command, name string) bool

CmdBool 读取配置Bool

func CmdString

func CmdString(cmd *cobra.Command, name string) string

CmdString 读取配置String

func Mkdir

func Mkdir(dir string) error

Mkdir 创建目录

Types

type Classifier

type Classifier struct {
	Named   map[string][]Face // 命名的人脸
	Waiting [][]Face          // 待命名的
	Rec     *face.Recognizer  // 人脸识别
}

Classifier 人脸分类器

func (*Classifier) Classify

func (c *Classifier) Classify(faces []*Face)

Classify 分类

Example
db, _ := NewDB("db")
defer db.Close()
faces := []*Face{}
db.Get([]byte("faces"), &faces)

rec, _ := face.NewRecognizer("data")
defer rec.Close()
c := Classifier{
	Rec:     rec,
	Named:   map[string][]Face{},
	Waiting: [][]Face{},
}
c.Classify(faces)
Output:
false <nil>

func (*Classifier) SetName

func (c *Classifier) SetName(id utils.ID, name string)

SetName 设置名称

type DB

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

DB 数据库对象

func NewDB

func NewDB(dir string) (*DB, error)

NewDB 新建数据库对象

Example
tmpDir := fmt.Sprintf("/tmp/%s", utils.NewID('D'))
db, _ := NewDB(tmpDir)
defer db.Close()

key := []byte{'1'}

fmt.Println(db.Has(key))
db.Put(key, "txt")
fmt.Println(db.Has(key))

var str string
db.Get(key, &str)
fmt.Println(str)
Output:
false <nil>
true <nil>
txt

func (*DB) Close

func (d *DB) Close() error

Close 关闭数据库

func (*DB) Delete

func (d *DB) Delete(key []byte) error

Delete 删除

func (*DB) Get

func (d *DB) Get(key []byte, p interface{}) error

Get 数据库数据读取

func (*DB) Has

func (d *DB) Has(key []byte) (bool, error)

Has 包含

func (*DB) Iterator

func (d *DB) Iterator(prefix []byte, f func(key, value []byte) bool) error

Iterator 迭代获取数据

func (*DB) Put

func (d *DB) Put(key []byte, obj interface{}) error

Put 保存数据

type Face

type Face struct {
	ID   utils.ID  // ID
	PID  []byte    // 照片文件ID
	Face face.Face // 人脸识别
}

Face 脸

func NewFace

func NewFace(f face.Face, pid []byte) *Face

NewFace 新建脸

type Photo

type Photo struct {
	Size  int64       // 尺寸
	Ca    time.Time   // 创建时间
	Faces []face.Face // 人脸识别
	Make  string      // 相机
	Model string      // 型号
}

Photo 照片处理

func NewPhoto

func NewPhoto(file string, rec *face.Recognizer) (photo *Photo, err error)

NewPhoto 照片信息

Example
rec, _ := face.NewRecognizer("data")
defer rec.Close()

b, err := NewPhoto("lareina.jpg", rec)
fmt.Println(err)
fmt.Printf("%d\n", len(b.Faces))

p, err := NewPhoto("has-lens-info.jpg", rec)
fmt.Println(err)
fmt.Println(p.Ca)
fmt.Println(p.Make, p.Model, p.Size)
Output:
<nil>
1
<nil>
2014-09-01 15:03:47 +0800 CST
Apple iPhone 4S 22493

Jump to

Keyboard shortcuts

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