face-blinder

FaceBlinder v0.0.12 Documentation

Classes

FaceBlinder

Typedefs

FaceBlinderOptions

Point Type

FaceBlinder

Kind: global class

new FaceBlinder([options])

Creates an instance of FaceBlinder.

Param Type
[options] FaceBlinderOptions

faceBlinder.init() ⇒ Promise.<void>

Init the FaceBlinder

Kind: instance method of FaceBlinder
Example

const faceBlinder = new FaceBlinder()
await faceBlinder.init()

faceBlinder.quit() ⇒ Promise.<void>

Quit FaceBlinder, should quit when not use facelinder

Kind: instance method of FaceBlinder
Example

await faceBlinder.quit()

faceBlinder.destroy() ⇒ Promise.<void>

Destroy FaceBlinder

Kind: instance method of FaceBlinder

faceBlinder.see(file) ⇒ Promise.<Array.<Face>>

See faces from the image file.

FaceBlinder should init first, then can see faces.

Example/see-face

Kind: instance method of FaceBlinder

Param Type
file string

Example

const faceBlinder = new FaceBlinder()
await faceBlinder.init()
const imageFile = `image/zhizunbao-zixia.jpg`
const faceList = await faceBlinder.see(imageFile)
console.log(faceList[0])

faceBlinder.similar(face, [threshold]) ⇒ Promise.<Array.<Face>>

Get All Similar Face from the database.

Example/find-similar-face

Kind: instance method of FaceBlinder

Param Type Default Description
face Face   the face to compare
[threshold] number this.threshold threshold to judge two faces similarity, defatult is 0.75, you can change the number you prefer.

Example

// faceBlinder should have some faces before, then it can get the similar face. Try Example/find-similar-face.ts
const faceList = await blinder.see(`image/zhizunbao-zixia.jpg`)
const similarFaceList = await blinder.similar(faceList[i])
for (const face of similarFaceList) {
  console.log(`Get ${similarFaceList.length} similar face.`)
}

faceBlinder.recognize(face) ⇒ Promise.<(string\|null)>

Recognize face and return all related face name(here equal to face md5) from database

Example/recogonize-face

Kind: instance method of FaceBlinder
Returns: Promise.<(string\|null)> - - faceNameList, a face md5 array

Param Type
face Face

Example

// Should remember the face before recogonize the face.
const faceList = await blinder.see(`image/zixia.jpg`)
await faceBlinder.remember(faceList[0], 'Zixia')
const recognizedName = await blinder.recognize(faceList[0]) || 'Who?'
console.log(`Recognize result: ${recognizedName}`)

faceBlinder.remember(face, [name]) ⇒ Promise.<(void\|string\|null)>

Remeber the face.

Kind: instance method of FaceBlinder

Param Type Description
face Face  
[name] string if not null, set the name for this face.
if null, the face name is face.md5 by default.

Example

const faceList = await blinder.see(`image/zixia.jpg`)
await faceBlinder.remember(faceList[0], 'Zixia')

faceBlinder.forget(face) ⇒ Promise.<void>

Forget the face in the database

Kind: instance method of FaceBlinder

Param Type
face Face

Example

const faceList = await blinder.see(`image/zixia.jpg`)
await faceBlinder.forget(faceList[0])

faceBlinder.file(face) ⇒ string

Save the face to file

Example/see-face

Kind: instance method of FaceBlinder
Returns: string - - return file directory

Param Type
face Face

Example

const faceList = await faceBlinder.see('image/zhizunbao-zixia.jpg')
for (const face of faceList) {
  const fileName = await faceBlinder.file(face)
  console.log(`Save file to ${fileName}`)
}

faceBlinder.face(md5) ⇒ Promise.<(Face\|null)>

Get face by md5

Kind: instance method of FaceBlinder

Param Type
md5 string

faceBlinder.list(md5Partial) ⇒ Promise.<Array.<string>>

Get face.md5 list from database based on partialmd5. Make it convenience for user find face by md5

Kind: instance method of FaceBlinder

Param Type
md5Partial string

Example

// just an example for a md5Partial, change a more similar partial as you like.
let md5Partial = `2436`
const md5List = await blinder.list(md5Partial)
if (md5List.length === 0) {
  console.log('no such md5')
} else if (md5List.length === 1) {
  consoel.log(`You find the face!, face md5: ${md5List[0]}`)
} else {
  const reply = [ `which md5 do you want?`, ...md5List,].join('\n')
  console.log(reply)
}

FaceBlinderOptions

Point Type

Kind: global typedef
Properties

Name Type Description
workdir string Workdir of the project, default: face-blinder.workdir
threshold number The number to judge the faces are the same one, default: 0.75