Point Type
Kind: global class
Promise.<void>Promise.<void>Promise.<void>Promise.<Array.<Face>>Promise.<Array.<Face>>Promise.<(string\|null)>Promise.<(void\|string\|null)>Promise.<void>stringPromise.<(Face\|null)>Promise.<Array.<string>>Creates an instance of FaceBlinder.
| Param | Type |
|---|---|
| [options] | FaceBlinderOptions |
Promise.<void>Init the FaceBlinder
Kind: instance method of FaceBlinder
Example
const faceBlinder = new FaceBlinder()
await faceBlinder.init()
Promise.<void>Quit FaceBlinder, should quit when not use facelinder
Kind: instance method of FaceBlinder
Example
await faceBlinder.quit()
Promise.<void>Destroy FaceBlinder
Kind: instance method of FaceBlinder
Promise.<Array.<Face>>See faces from the image file.
FaceBlinder should init first, then can see faces.
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])
Promise.<Array.<Face>>Get All Similar Face from the database.
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.`)
}
Promise.<(string\|null)>Recognize face and return all related face name(here equal to face md5) from database
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}`)
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')
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])
stringSave the face to file
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}`)
}
Promise.<(Face\|null)>Get face by md5
Kind: instance method of FaceBlinder
| Param | Type |
|---|---|
| md5 | string |
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)
}
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 |