3.0.9 • Published 9 months ago

@privateid/small-age-sdk-alpha v3.0.9

Weekly downloads
-
License
See AWS EULA Temp...
Repository
github
Last release
9 months ago

Powered by Private Identity® https://private.id

BENEFITS

BUILD

Prerequisite

Sign up on the waitlist on https://private.id to obtain your apiKey.

Installation

npm install @privateid/cryptonets-web-sdk

Copy the necessary dependencies to the public folder of your app

"prestart": "cp -R ./node_modules/@privateid/cryptonets-web-sdk/wasm public/&& cp -R ./node_modules/@privateid/cryptonets-web-sdk/workers public/",
"prebuild": "cp -R ./node_modules/@privateid/cryptonets-web-sdk/wasm public/ && cp -R ./node_modules/@privateid/cryptonets-web-sdk/workers public/"

Add the necessary environment variables on the .env file in the root of your project

SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL= 
REACT_APP_API_KEY=
REACT_APP_WASM_MODULE= face_mask | face | voice

Optional environment variable

REACT_APP_API_ORCHESTRATION=
REACT_APP_SET_CACHE= true | false (Used for predict caching)

Load the WASM Module

The first step is to load and initialize the wasm module and clear the content of the local database.

import { loadPrivIdModule, clearDB } from '@privateid/cryptonets-web-sdk';

const isSupported = await loadPrivIdModule();
clearDB();

In case of .env file (evironment variable) does not work for you we have added a support to set the variables on load.

import { loadPrivIdModule } from '@privateid/cryptonets-web-sdk';

const isSupported =await loadPrivIdModule(
  api_url, 
  api_key,
  api_orchestration_url,
  wasm_url,
  wasm_module,
);
StatusDescription
api_urlEquivalent to env variable REACT_APP_API_URL
api_keyEquivalent to env variable REACT_APP_API_KEY
api_orchestration_urlEquivalent to env variable REACT_APP_API_ORCHESTRATION_URL
wasm_urlPlease set it the same with api_url or REACT_APP_API_URL
wasm_moduleface_mask , face , voice

The loadPrivIdModule() function returns an object to check if the device is supporting WASM and WebRTC.

{
    support: boolean,
    message: string,
}

Open or switch camera or close camera

The first step is to load and initialize the wasm module.

Open the camera

To open user camera use the openCamera function with element id of the video tag in the DOM

import { openCamera } from '@privateid/cryptonets-web-sdk';

const { devices, faceMode } = await openCamera(element);

it returns list of the available video devices.

Switch to another camera

To switch to another media device use the switchCamera function with the ID of the device to be used

import { switchCamera } from '@privateid/cryptonets-web-sdk';

switchCamera(deviceID);

for the mobile phone we can select whether it's front or back camera for this we pass 'front' or 'back' to the switch function

import { switchCamera } from '@privateid/cryptonets-web-sdk';

switchCamera('front');

Close the camera

To close user camera use the closeCamera function with element id of the video tag in the DOM.

import { closeCamera } from '@privateid/cryptonets-web-sdk';

closeCamera(element); // Will specifically look for the element id and will close that camera
closeCamera(); // By default will close opened camera using openCamera

Predict Age

Perform an age estimation using predictAge function on all detected faces from image or camera.

import { predictAge } from '@privateid/cryptonets-web-sdk';

await predictAge(null, predictAgeCallback);

The function takes 3 parameters

PropertyDescription
imageDataIf this parameter is provided it will check age of the imageData instead of opened camera.
callbackThe callback function to handle predictAge results.

Callback

Here are sample returned data to callback from predictAge :

{
    "status": "WASM_RESPONSE",
    "returnValue": {
        "error": 0,
        "faces": [
            {
                "status": 0,
                "age": 16.912670135498047,
                "box": {
                    "top_left": {
                        "x": 486,
                        "y": 371
                    },
                    "bottom_right": {
                        "x": 652,
                        "y": 545
                    }
                }
            },
        ]
    }
}
3.0.8

9 months ago

3.0.9

9 months ago

3.0.7

9 months ago

3.0.6

9 months ago

3.0.5

9 months ago

3.0.5-alpha

9 months ago

3.0.1-alpha

1 year ago

3.0.4-alpha

1 year ago

3.0.0-alpha

1 year ago

3.0.3-alpha

1 year ago

3.0.2-alpha

1 year ago

2.0.40-alpha

1 year ago

2.0.38-alpha

1 year ago

2.0.39-alpha

1 year ago

2.0.37-alpha

1 year ago

2.0.36-alpha

1 year ago

2.0.34-alpha

1 year ago

2.0.35-alpha

1 year ago

2.0.32-alpha

1 year ago

2.0.33-alpha

1 year ago

2.0.31-alpha

1 year ago

2.0.30-alpha

1 year ago

2.0.26-alpha

2 years ago

2.0.25-alpha

2 years ago

2.0.23-debug

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

2.0.2-alpha

2 years ago

2.0.11-alpha

2 years ago

1.0.3

2 years ago

1.0.6-alpha

2 years ago

2.0.5-alpha

2 years ago

2.0.16-debug

2 years ago

1.1.1-alpha

2 years ago

1.0.11-alpha

2 years ago

1.2.2-alpha

2 years ago

1.1.4-alpha

2 years ago

1.0.5-alpha

2 years ago

2.0.1-alpha

2 years ago

2.0.20-debug

2 years ago

1.1.0-alpha

2 years ago

2.0.17-debug

2 years ago

2.0.15-debug

2 years ago

2.0.7-alpha

2 years ago

1.0.8-alpha

2 years ago

1.2.1-alpha

2 years ago

2.0.4-alpha

2 years ago

1.1.3-alpha

2 years ago

0.0.18

2 years ago

2.0.0-alpha

2 years ago

2.0.10-alpha

2 years ago

2.0.21-debug

2 years ago

2.0.19-debug

2 years ago

1.1.2-alpha

2 years ago

2.0.3-alpha

2 years ago

1.0.4-alpha

2 years ago

1.1.5-alpha

2 years ago

2.0.22-debug

2 years ago

1.2.0-alpha

2 years ago

1.0.12-alpha

2 years ago

2.0.6-alpha

2 years ago

1.0.7-alpha

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago