EyePop.ai has introduced a dedicated npm package for JavaScript developers, streamlining the process of integrating your Pop in the web. This package ensures an efficient and user-friendly setup experience.
Refer to the following page to quickly get the EyePopSDK JavaScript demo repository up and running on your local machine.
SDK Usage
Here's a barebones example of the SDK for uploading and displaying an image with object identification overlays.
<form></form><divstyle="height: 600px; width:600px;"></div><scriptsrc="https://cdn.jsdelivr.net/npm/@eyepop.ai/javascript-sdk"></script><script>var config = {};// replace with your endpoint UUIDconstpop_uuid='<POP_UUID>'; // leave this empty to launch a 'login' popup, or enter a temporary token consttoken=''; // first, fetch the Pop info EyePopSDK.EyePopAPI.FetchPopConfig(pop_endpoint, token).then((response) => { config = response;config.input = {"name":"file_upload" };console.log("EyePopSDK config: ", config);// then start the PopEyePopSDK.EyePopSDK.init(config); });</script>
The initialization function required for the SDK. This starts all media streaming and uploading, as well as drawing on top of the provided canvas. This object is created with a call to EyePopAPI.FetPopConfig(pop_endpoint, token) and appended to with the following options:
Parameters:
config.input
This is where to set a Pop's media input type and source is set.
config.draw
The SDK supports an array of drawing methods, organized alphabetically by type. To use, you must change the Draw parameter on the config object used to initiate the EyePopSDK.
Overwrite the config.Draw object to enable or disable drawing passes. Pass an empty array to disable all drawings.
User configurable elements of the config are as follows:
// An array of objects, each specifying a different drawing pass. You are free to enable as many drawing passes as required.config.draw= [ {} ]// A string, options include: "box", "pose", "hand", "face", "posefollow", "clip", "custom"config.draw[ i ].type=""// An array of strings, options include: "*", "people",config.draw[ i ].targets= [ "" ] // An array of strings, options include all pose labels, such as "right eye", "left eye", etcconfig.draw[ i ].anchors= [ "" ] // A string path to an image to be anchored to our Anchor points, ex: "./fun/sunglasses3.png?raw=true", config.draw[ i ].image=""// A number to scale the anchored image by, ex: 2.6config.draw[ i ].scale=2.6
Draw Types
box:
Targets: Specific objects or parts of objects you wish to encircle within a box. E.g., "person.face". A value of "*" means all labels.
box with Tracking:
Targets: A list of objects to enclose within a box. E.g., "apple", "backpack", and more. A value of "*" means all labels.
Tracking:
Tracking allows you to receive a unique ID for each person in a scene. This ID is held stable while a person remains on screen. Tracking has to be turned on for your account so please ask an EyePop.ai Team member to turn this on for you.
Labels: An array of assigned labels for the tracking augmentation.
pose:
Targets: Currently, in the present version, the pose type can only target "person", highlighting body key points.
posefollow:
Targets: Objects like "person" that you aim to track. A value of "*" means all labels.
Anchors: Specific points within the target object where the augmentation is anchored, such as "right wrist".
Image: The image placed at the anchor point, like "./images/sunglasses3.png".
The Rules class has been specifically crafted for processing the outputs of EyePop.ai's computer vision system. It provides functionalities to construct semantic rules, helping in the identification and extraction of specific features and attributes from photos and videos.
FindObject(label, object)
Purpose: Filters the provided list of objects based on the specified class label.
Parameters:
‘label’: String representing the class label of the desired object.
‘objects’: Array of objects.
Returns:
Array of objects that match the specified class label.
// An object with the following properties:config.input= {} // A string name of the input media, options are: "webcam_on_page", "screen", "webcam_off_site", "url", "file_upload"=""// A string url of the input media, ex: "https://www.example.com/video.mp4"=""