api.video media stream person segmentation - change the background and emphasize the person in your media streams
npm install @api.video/media-stream-person-segmentation



api.video is the video infrastructure for product builders. Lightning fast
video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in
your app.
- Table of contents
- Project description
- Getting started
- Installation
- Simple include in a javascript project
- Documentation
- Instanciation
- Options
- Methods
- applyBlurEffect(options: BlurEffectOptions)
- Options
- onReady(callback: (stream: MediaStream) => void)
- Full example
This library allows you to easily blur the background of a webcam video stream in real-time using TensorFlow.
With this library, you can create a more professional and visually appealing video conferencing experience by keeping the focus on the person in front of the camera and reducing visual distractions from the surrounding environment.
Please note that this project is currently experimental and may not be suitable for production use. This works pretty well on Chrome and Firefox, it may not work as well on Safari.
Include the library in your HTML file like so:
``html`
...
`html`
...
The library is instanciated with a MediaStream object as parameter.
`javascript`
const segmentation = new ApiVideoMediaStreamPersonSegmentation(webcamStream)
Apply a blur effect on the background of the video stream.
#### Options
| Name | Default | Type | Description |
| :------ | :------| :------ | :------ |
| backgroundBlurAmount | 15 | number | The amount of blur to apply to the background. |
| edgeBlurAmount | 8 | number | The amount of blur to apply to the edges of the person. |
`javascript`
segmentation.applyBlurEffect({
backgroundBlurAmount: 15,
edgeBlurAmount: 8
})
`javascript`
segmentation.onReady((stream) => {
// use the stream to display the video
// ...
});
`html
``