JavaScript SDK is based on the Nvision image processing service as Promise based function call and WebSocket client with TypeScript definition provided.
You do not have to provide both apiKey or streamingKey . If you use only API call, you can provide only apiKey , this applied to WebSocket streaming too.
Making an API call
You can make an API call using predict() function of the service object
import nvision from"@nipacloud/nvision";constobjectDetectionService=nvision.objectDetection({ apiKey:"<YOUR_RESTFUL_KEY>"});objectDetectionService.predict("BASE64_ENCODED_IMAGE").then((result) => {// Outout the result object to consoleconsole.log(result);});
Streaming video frames through WebSocket
You can make a WebSocket connection using stream() generator function to get the streaming client object.
Set "OutputCroppedImage" parameter, if true, API response will include the cropped images for each bounding box in Base64 encoded JPEG/PNG format. Default is false.
confidenceThreshold (optional)
Set "ConfidenceThreshold" parameter" to define the minimum confidence score of the prediction results.
outputVisualizedImage (optional)
Set "OutputVisualizedImage" parameter to return drawn detection objects on raw image
Field
service_id
Service ID associated to the API key used
detected_object
List of the detected objects
name
Classified name of the object
confidence
Confidence value of the prediction
cropped_image
Bounding box cropped image
Field
Description
on()
Add an event subscriber, Possible event are "connect", "message", "error"
once()
Add a one-time event subscriber, Possible event are "connect", "message", "error"