Here is an example of how to make a faceRecoRegisterUser request using the NEST® SDK:
// import the ai-core-sdkconstfs=require('fs');import {AIServices} from'@nest25/ai-core-sdk';// reusable arrow function to encode file data to base64 encoded stringconstconvertBase64=async (path) => {// get the extention of the imagelet words =path.split('.')let extention =words.pop();// read binary data from fileconstbitmap=fs.readFileSync(path);// convert the binary data to base64 encoded stringlet base64String =bitmap.toString('base64');return`data:image/${extention};base64,${base64String}`;};// relative path to the fileconstfilePath='playground/sample.jpg';// create a new instance of the sdkconstaiServices=newAIServices();asyncfunctionmain() {// get the result of the testlet result =awaitconvertBase64(filePath);constresult=awaitaiServices.faceRecoCompareFaceWithId('user_id', result);console.log(result);}main();
Response
{"status":1,"message":"User photo matches with the id."}
Last updated
Parameter
Type
Description
Parameter
Type
Description
profileId
string
unique profile id of the user, in case duplicate user will not be created
image
string
base64 image data of the user id
message
string
message about the response
status
int
0 for user id already exists
1 for successful execution and user creation
-1 for any error occurs during the execution of the request