facebetter 1.0.14 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +157 -0
- package/dist/facebetter.esm.js +349 -85
- package/dist/facebetter.esm.js.map +1 -1
- package/dist/facebetter.js +348 -85
- package/dist/facebetter.js.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Facebetter Web SDK
|
|
2
|
+
|
|
3
|
+
<h2 align="center">
|
|
4
|
+
<a href="https://github.com/pixpark/facebetter-demo"><img src="./logo.svg" alt="Facebetter Logo" width="300"></a>
|
|
5
|
+
</h2>
|
|
6
|
+
|
|
7
|
+
Facebetter is a high-performance, cross-platform SDK for real-time face beauty and AR effects. The Web version leverages WebAssembly (WASM) and WebGL acceleration to provide professional-grade skin retouching, face reshaping, makeup, and virtual background capabilities directly in the browser.
|
|
8
|
+
|
|
9
|
+
🔗 **Quick Links**
|
|
10
|
+
- [Official Website](https://facebetter.net)
|
|
11
|
+
- [Documentation](https://facebetter.net/docs.html)
|
|
12
|
+
- [Live Demo](https://demo.facebetter.net/)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🌟 Key Features
|
|
17
|
+
|
|
18
|
+
- **Extreme Performance**: Optimized with WASM and SIMD instructions for low-latency, real-time processing on all modern browsers.
|
|
19
|
+
- **Advanced Skin Retouching**: Smoothing, whitening, rosy tint, and sharpening for a natural, high-end look.
|
|
20
|
+
- **Precise Face Reshaping**: Comprehensive adjustments for face thinning, V-shape, eye enlargement, nose slimming, and chin/forehead contouring.
|
|
21
|
+
- **Professional Makeup**: Real-time application of lipstick, blush, and more with parametric intensity control.
|
|
22
|
+
- **AI Virtual Background**: High-precision portrait segmentation for background blur and custom image replacement.
|
|
23
|
+
- **Premium Effects**: Includes 20+ real-time filters, animated stickers (in development), and professional-grade Chroma Key (Green Screen) removal.
|
|
24
|
+
- **Developer Friendly**: Clean, well-documented JS API. Integrated in minutes with support for various input sources (Image, Video, Canvas, ImageData).
|
|
25
|
+
- **Cross-Platform Consistency**: Shared core algorithms with Android, iOS, and Desktop SDKs ensure a unified experience across all devices.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 📦 Installation
|
|
30
|
+
|
|
31
|
+
### via npm (Recommended)
|
|
32
|
+
|
|
33
|
+
Ideal for modern frontend environments like Vite, Webpack, React, or Vue.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install facebetter
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### via CDN
|
|
40
|
+
|
|
41
|
+
For direct browser usage.
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<!-- Import SDK via CDN -->
|
|
45
|
+
<script src="https://cdn.jsdelivr.net/npm/facebetter/dist/facebetter.js"></script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🚀 Quick Start
|
|
51
|
+
|
|
52
|
+
### 1. Initialize the Engine
|
|
53
|
+
|
|
54
|
+
Facebetter supports both online activation via `appId` / `appKey` and offline activation via `licenseJson`.
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { BeautyEffectEngine, EngineConfig } from 'facebetter';
|
|
58
|
+
|
|
59
|
+
// 1. Configure the engine
|
|
60
|
+
const config = new EngineConfig({
|
|
61
|
+
appId: 'YOUR_APP_ID',
|
|
62
|
+
appKey: 'YOUR_APP_KEY',
|
|
63
|
+
// Or use offline license
|
|
64
|
+
// licenseJson: '{...}'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// 2. Create engine instance
|
|
68
|
+
const engine = new BeautyEffectEngine(config);
|
|
69
|
+
|
|
70
|
+
// 3. Initialize (Loads WASM resources and performs authentication)
|
|
71
|
+
try {
|
|
72
|
+
await engine.init();
|
|
73
|
+
console.log('Facebetter Engine initialized successfully');
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('Initialization failed:', error);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. Configure Beauty Parameters
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { BeautyType, BasicParam, ReshapeParam } from 'facebetter';
|
|
83
|
+
|
|
84
|
+
// Enable specific beauty modules
|
|
85
|
+
engine.setBeautyTypeEnabled(BeautyType.Basic, true); // Basic skin retouching
|
|
86
|
+
engine.setBeautyTypeEnabled(BeautyType.Reshape, true); // Face reshaping
|
|
87
|
+
|
|
88
|
+
// Set skin smoothing intensity (0.0 - 1.0)
|
|
89
|
+
engine.setBasicParam(BasicParam.Smoothing, 0.8);
|
|
90
|
+
// Set eye enlargement intensity (0.0 - 1.0)
|
|
91
|
+
engine.setReshapeParam(ReshapeParam.EyeSize, 0.5);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. Process Video Stream
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
const videoElement = document.querySelector('video');
|
|
98
|
+
const canvas = document.querySelector('canvas');
|
|
99
|
+
const ctx = canvas.getContext('2d');
|
|
100
|
+
|
|
101
|
+
function processFrame() {
|
|
102
|
+
if (engine.initialized) {
|
|
103
|
+
// Process the current frame and get the result as ImageData
|
|
104
|
+
const resultData = engine.processImage(videoElement);
|
|
105
|
+
|
|
106
|
+
// Render to your canvas
|
|
107
|
+
if (resultData) {
|
|
108
|
+
ctx.putImageData(resultData, 0, 0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
requestAnimationFrame(processFrame);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
processFrame();
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🛠️ API Overview
|
|
120
|
+
|
|
121
|
+
### Core Methods
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
| :--- | :--- |
|
|
125
|
+
| `init()` | Asynchronously initializes the engine and loads assets. |
|
|
126
|
+
| `setBeautyTypeEnabled(type, enabled)` | Toggle specific modules (Basic, Reshape, Makeup, Background). |
|
|
127
|
+
| `setBasicParam(param, value)` | Adjust skin retouching settings (Smoothing, Whitening, etc.). |
|
|
128
|
+
| `setReshapeParam(param, value)` | Adjust face reshaping settings (Thinning, Eye Size, etc.). |
|
|
129
|
+
| `setMakeupParam(param, value)` | Adjust makeup intensity (Lipstick, Blush, etc.). |
|
|
130
|
+
| `setFilter(path, intensity)` | Apply a LUT filter with custom intensity. |
|
|
131
|
+
| `setVirtualBackground(options)` | Configure background blur or image replacement. |
|
|
132
|
+
| `processImage(source)` | Process an input source (Image, Video, Canvas, or ImageData). |
|
|
133
|
+
| `destroy()` | Clean up resources and release WebAssembly memory. |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## ⚠️ Important Notes
|
|
138
|
+
|
|
139
|
+
1. **WASM Asset Path**: By default, the SDK expects WASM and asset bundles in the `/facebetter/` directory. Ensure your static asset server is configured correctly.
|
|
140
|
+
2. **Secure Context**: The SDK requires a Secure Context (HTTPS or localhost) to access modern browser features.
|
|
141
|
+
3. **Performance Optimization**:
|
|
142
|
+
- Always call `processImage` within a `requestAnimationFrame` loop.
|
|
143
|
+
- Match input resolution with the display canvas to avoid unnecessary scaling overhead.
|
|
144
|
+
4. **Memory Management**: Always call `engine.destroy()` when the engine is no longer needed to prevent memory leaks in Single Page Applications (SPAs).
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 📄 Licensing & Support
|
|
149
|
+
|
|
150
|
+
Facebetter offers a **Free Tier** and **Enterprise Licensing**:
|
|
151
|
+
- **Free Tier**: 5,000 free minutes per month, including all Pro+ features (with watermark).
|
|
152
|
+
- **Enterprise**: Watermark-free, usage-based or perpetual licensing with priority support.
|
|
153
|
+
|
|
154
|
+
- For technical support, visit [Facebetter.net](https://facebetter.net).
|
|
155
|
+
- For commercial licensing inquiries, contact [sales@pixpark.net](mailto:sales@pixpark.net).
|
|
156
|
+
|
|
157
|
+
Copyright © 2025 Pixpark. All rights reserved.
|