sm-ai-pose-generator
v1767000.207.310
Published
Professional integration for https://supermaker.ai/image/ai-pose-generator/
Maintainers
Readme
sm-ai-pose-generator
A JavaScript library to generate AI-assisted pose estimations from images. This package provides a simple and efficient way to extract pose information for various applications.
Installation
Install the package using npm: bash npm install sm-ai-pose-generator
Usage Examples
Here are a few examples demonstrating how to use the sm-ai-pose-generator package in your JavaScript projects:
1. Basic Pose Estimation: javascript const poseGenerator = require('sm-ai-pose-generator');
async function estimatePose(imagePath) { try { const poseData = await poseGenerator.estimate(imagePath); console.log("Pose estimation data:", poseData); // Process the pose data, e.g., display keypoints on an image. } catch (error) { console.error("Error during pose estimation:", error); } }
// Example usage: estimatePose('path/to/your/image.jpg');
2. Configuration Options: javascript const poseGenerator = require('sm-ai-pose-generator');
async function estimatePoseWithConfig(imagePath) { const config = { modelType: 'lightweight', // Options: 'lightweight', 'accurate' scoreThreshold: 0.5, // Minimum confidence score for keypoints };
try { const poseData = await poseGenerator.estimate(imagePath, config); console.log("Pose estimation data with config:", poseData); } catch (error) { console.error("Error during pose estimation:", error); } }
// Example usage: estimatePoseWithConfig('path/to/your/image.jpg');
3. Handling Multiple Poses (if supported by the underlying model): javascript const poseGenerator = require('sm-ai-pose-generator');
async function estimateMultiplePoses(imagePath) {
try {
const poseDataArray = await poseGenerator.estimate(imagePath, { maxPoses: 5 }); // Request up to 5 poses
if (Array.isArray(poseDataArray)) {
poseDataArray.forEach((pose, index) => {
console.log(Pose ${index + 1}:, pose);
});
} else {
console.log("Single pose detected:", poseDataArray); // Handle the case where only one pose is returned.
}
} catch (error) {
console.error("Error during pose estimation:", error);
}}
// Example usage: estimateMultiplePoses('path/to/your/image_with_multiple_people.jpg');
4. Using with Streams (Node.js): javascript const fs = require('fs'); const poseGenerator = require('sm-ai-pose-generator');
async function estimatePoseFromStream(imagePath) { const imageStream = fs.createReadStream(imagePath);
try { const poseData = await poseGenerator.estimate(imageStream); console.log("Pose estimation data from stream:", poseData); } catch (error) { console.error("Error during pose estimation:", error); } }
// Example usage: estimatePoseFromStream('path/to/your/image.jpg');
API Summary
estimate(imagePath: string | Buffer | Stream, config?: object): Promise<object | array>Estimates the pose(s) in the provided image.
imagePath: The path to the image file, a Buffer containing image data, or a Readable Stream.config(optional): An object containing configuration options:modelType(string): Specifies the model to use. Options:'lightweight'(default),'accurate'.scoreThreshold(number): A value between 0 and 1 representing the minimum confidence score for keypoints. Default:0.5.maxPoses(number): The maximum number of poses to detect (if the model supports multiple poses).
Returns a Promise that resolves with the pose estimation data (an object representing a single pose, or an array of pose objects if multiple poses are detected). Rejects with an error if pose estimation fails.
License
MIT License
This package is part of the sm-ai-pose-generator ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/image/ai-pose-generator/
