npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@privateid/small-age-sdk

v2.0.3

Published

Age SDK

Downloads

20

Readme

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,
);

| Status | Description | |---------------|---------------------------------------------------------------------------------| | api_url | Equivalent to env variable REACT_APP_API_URL | | api_key | Equivalent to env variable REACT_APP_API_KEY | | api_orchestration_url | Equivalent to env variable REACT_APP_API_ORCHESTRATION_URL | | wasm_url | Please set it the same with api_url or REACT_APP_API_URL | | wasm_module | face_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

| Property | Description | |----------|--------------------------------------------| | imageData | If this parameter is provided it will check age of the imageData instead of opened camera. | | callback | The 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
                    }
                }
            },
        ]
    }
}