Constructor
new IFace(baseURLopt)
Example
const iface = new IFace()
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
baseURL |
string |
<optional> |
Protocol, domain, and port for the service. |
Methods
(async) icao(image, cropopt, backgroundopt) → {object}
Example
// Take a photo with a Canon Camera and perform ICAO checks on the
// returned image
const camera = new CanonCamera()
const photo = await camera.takePhoto('base64')
const iface = new IFace()
const results = await iface.icao(photo)
const img = document.createElement('img')
img.src = 'data:image/jpeg;base64,' + results.cropped
console.log(`found ${result.faces_found} faces in the image`)
document.body.appendChild(img)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image |
string | A base64 encoded image. |
||
crop |
string | bool |
<optional> |
If falsy image will not be cropped, otherwise the value will be interpreted as the preferred crop method which will vary by plugin implementation. |
|
background |
string |
<optional> |
#ffffff
|
Hexadecimal color that will fill in any part of the cropped image that falls outside the original source image. |
Returns:
Results of the ICAO check, this may vary by plugin implementation.
- Type
- object
(async) match(probe, candidates, modeopt)
Example
// Create an iface object
const iface = new IFace()
// Obtain a photo for the probe photo
const probe = await camera.takePhoto('base64')
// Create a candidate set from the person's previous photos
const candidates = [
new Candidate('/person/1/photo/2.jpg', '3', 'url'),
new Candidate('/person/1/photo/1.jpg', '2', 'url')
]
// Match the probe to all the candidates using the 'balanced' mode
const results = await iface.match(probe, candidates, 'balanced')
// use the results
console.log(results)
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
probe |
object | string | Either a Probe object or a base64 encoded image that is being compared or searched against one or more candidates |
||||||||||||||||||
candidates |
Array.<object> | An array of candidate objects against which the probe photo is compared. Properties
|
||||||||||||||||||
mode |
string |
<optional> |
fast
|
Matching mode to use for all images, can be overriden on each candidate if desired. Valid values are: 'accurate', 'balanced', 'fast', and 'accurate_server'. |
(async) matchModes() → {Array.<string>}
Example
const iface = new IFace()
const modes = await iface.matchModes()
// do something with modes, such as build a <select> element
const select = document.createElement('select')
modes.forEach(mode => {
const option = document.createElement('option')
option.value = mode
select.appendChild(mode)
})
document.body.appendChild(select)
Returns:
List of available face matching modes
- Type
- Array.<string>