ai-pose-generator-1
v1766998.844.96
Published
Professional integration for https://supermaker.ai/image/ai-pose-generator/
Maintainers
Readme
ai-pose-generator-1
A lightweight JavaScript library for generating AI-powered pose estimations from images. This utility allows developers to quickly integrate pose detection capabilities into their applications.
Installation
Install the package using npm: bash npm install ai-pose-generator-1
Usage Examples
Here are a few examples demonstrating how to use ai-pose-generator-1 in your JavaScript projects.
1. Basic Pose Estimation from a Local Image File (Node.js):
This example demonstrates how to load an image from a local file and process it to generate pose estimations. javascript const aiPoseGenerator = require('ai-pose-generator-1'); const fs = require('fs');
// Read the image file as a Buffer const imageBuffer = fs.readFileSync('path/to/your/image.jpg');
aiPoseGenerator.estimatePose(imageBuffer) .then(poses => { console.log('Detected poses:', poses); }) .catch(error => { console.error('Error estimating pose:', error); });
2. Pose Estimation from a URL (Browser or Node.js):
This example shows how to fetch an image from a URL and generate pose estimations. It uses node-fetch for Node.js environment, but standard fetch API can be used in the browser.
javascript
// Node.js:
const aiPoseGenerator = require('ai-pose-generator-1');
const fetch = require('node-fetch');
// Browser: Remove the fetch import and use the browser's built-in fetch API.
const imageUrl = 'https://example.com/image.jpg';
fetch(imageUrl) .then(response => response.buffer()) .then(imageBuffer => aiPoseGenerator.estimatePose(imageBuffer)) .then(poses => { console.log('Detected poses:', poses); }) .catch(error => { console.error('Error estimating pose:', error); });
3. Processing Image Data Directly (Browser):
This example demonstrates how to pass image data directly from a <canvas> element for pose estimation.
javascript
// Assuming you have an image loaded in a canvas element
const canvas = document.getElementById('myCanvas');
const imageData = canvas.toDataURL('image/jpeg'); // Or other supported format
aiPoseGenerator.estimatePose(imageData) .then(poses => { console.log('Detected poses:', poses); }) .catch(error => { console.error('Error estimating pose:', error); });
**4. Custom Configuration (optional):**javascript const aiPoseGenerator = require('ai-pose-generator-1');
const config = { detectionThreshold: 0.8, // Adjust detection sensitivity (0.0 - 1.0) maxPoses: 5 // Limit the number of poses detected };
const imageUrl = 'https://example.com/image.jpg';
fetch(imageUrl) .then(response => response.buffer()) .then(imageBuffer => aiPoseGenerator.estimatePose(imageBuffer, config)) .then(poses => { console.log('Detected poses:', poses); }) .catch(error => { console.error('Error estimating pose:', error); });
API Summary
estimatePose(imageData: Buffer | string, config?: object): Promise<Array<Pose>>:- Estimates poses from the provided image data.
imageData: A Buffer containing image data (e.g., fromfs.readFileSync()) or a base64 encoded string.config(optional): An object containing configuration options. Supported options include:detectionThreshold: A number between 0.0 and 1.0 representing the minimum confidence score for a pose to be considered valid (default: 0.5).maxPoses: An integer representing the maximum number of poses to detect in the image (default: 10).
- Returns a Promise that resolves to an array of
Poseobjects, each representing a detected pose. EachPoseobject will contain keypoint information (e.g., coordinates of joints). The precise structure of thePoseobject depends on the underlying AI model and may be subject to change in future versions.
License
MIT License
This package is part of the ai-pose-generator-1 ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/image/ai-pose-generator/
