Kairos is the easist way add Face-Recognition to your web applications. Our API provides a full-featured and robust Face-Recognition backend, right out of the box. This is the Javascript wrapper for the Kairos Facial Recognition API. The package includes a client (kairos.js) you can use as an easy client to the API. Continue reading to learn how to integrate Kairos into your web application.
Thanks to contributions by some of our customers, we also have Ruby and .NET wrappers available. Also see our PHP SDK, our Android SDK and our iOS SDK.
- jQuery.
- A web browser.
- Basic knowledge of Javascript and HTML5.
If you just want to do a quick test run, open one of the example scripts included with the SDK and follow these steps:
- Create your free developer account
- Log into the Kairos Developer Dashboard
- Create an application and copy your App Id & App Key
- Paste them into the constructor method in example_detect.html (must be hosted)
- Open the script in your browser.
- Drag an image into the drop zone and wait for the response.
You can also test all of the Kairos API endpoints by running methods_test.html in your browser.
- Create your free Kairos developer account if you don't already have one.
- Log into the dashboard and create a new app.
- Copy your App ID & App Key (you'll need them later).
- Download the SDK and unzip the package.
- Open the folder named Kairos-SDK-Javascript and locate the kairos.js file.
- Place the client file (kairos.js) somewhere within your project.
- Include kairos.js where needed in your project.
<script src="assets/js/kairos.js"></script>
Before you can make API calls you'll need to pass Kairos your credentials App Id and App Key (You only need to do this once). Paste your App Id and App Key into the constructor method like so:
// instantiates a new instance of the Kairos client
var kairos = new Kairos("app_id", "api_key");
This method returns a list of all galleries you've created:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) pass your callback to the function
kairos.viewGalleries(myCallback);
This method returns a list of all subjects for a given gallery:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var gallery_name = 'friends1';
// (3) pass your params and callback to the function
kairos.viewSubjectsInGallery(gallery_name, myCallback);
This method removes a subject from given gallery:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var subject_id = 'sam';
var gallery_name = 'friends1';
// (3) pass your params and callback to the function
kairos.removeSubjectFromGallery(subject_id, gallery_name, myCallback);
This method removes a given gallery:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var gallery_name = 'friends1';
// (3) pass your params and callback to the function
kairos.removeGallery(gallery_name, myCallback);
The Enroll method registers a face for later recognitions. Here's an example of enrolling a face (subject) using a method that accepts an image URL or image data in base64 format, and enrolls it as a new subject into your specified gallery:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var image = '/images/myphotos/myphoto123.png'; (URL)
(or)
var image = 'iVBORw0KGgoAAA ... ABJRU5ErkJggg==\r\n'; (base64)
var subject_id = 'eric';
var gallery_name = 'friends1';
// (3) pass your params and callback to the function
kairos.enroll(image, gallery_name, subject_id, myCallback);
The SDK also includes a file upload field, which converts a local image file to base64 data.
The Recognize method takes an image of a subject and attempts to match it against a given gallery of previously-enrolled subjects. Here's an example of recognizing a subject using a method that accepts an image URL or image data in base64 format, sends it to the API, and returns a match and confidence value:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var image = '/images/myphotos/myphoto123.png'; (URL)
(or)
var image = 'iVBORw0KGgoAAA ... ABJRU5ErkJggg==\r\n'; (base64)
gallery_name = 'friends1';
// (3) pass your params and callback to the function
kairos.recognize(image, gallery_name, myCallback, options);
The SDK also includes a file upload field, which converts a local image file to base64 data.
The Detect method takes an image of a subject and returns various attributes pertaining to the face features. Here's an example of using detect via method that accepts an image URL or image data in base64 format, sends it to the API, and returns face attributes:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var image = '/images/myphotos/myphoto123.png'; (URL)
(or)
var image = 'iVBORw0KGgoAAA ... ABJRU5ErkJggg==\r\n'; (base64)
// (3) pass your params and callback to the function
kairos.detect(image, myCallback, options);
The SDK also includes a file upload field, which converts a local image file to base64 data.
The Verify method takes an image and verifies that it matches an existing subject in a gallery. Here's an example of using verify via method that accepts a path to an image file, sends it to the API, and returns face attributes:
// (1) set up your callback method
function myDetectCallback(response)
{
alert(response.responseText);
}
// (2) prepare your parameters
var image = '/images/myphotos/myphoto123.png'; (URL)
(or)
var image = 'iVBORw0KGgoAAA ... ABJRU5ErkJggg==\r\n'; (base64)
var subject_id = 'eric';
var gallery_name = 'friends1';
// (3) pass your params and callback to the function
kairos.verify(image, gallery_name, subject_id, callback);
The SDK also includes a file upload field, which converts a local image file to base64 data.
##Support Have an issue? Visit our Support page or create an issue on GitHub
Test on RapidAPI