- π Use latest MediaPipe Solution
- π Written in TypeScript
handleEffectImage(image, { type: TYPE.BLUR }, ({ imageData, width, height }) => {
canvas.width = width;
canvas.height = height;
canvas.getContext("2d")?.putImageData(imageData, 0, 0);
});
handleEffectImage(image, { type: TYPE.BG_COLOR, color: "blue" }, ({ imageData, width, height }) => {
canvas.width = width;
canvas.height = height;
canvas.getContext("2d")?.putImageData(imageData, 0, 0);
});
handleEffectImage(image, { type: TYPE.CROP }, ({ imageData, width, height }) => {
canvas.width = width;
canvas.height = height;
canvas.getContext("2d")?.putImageData(imageData, 0, 0);
});
handleEffectImage(image, { type: TYPE.IMAGE, imgSrc: bgImg }, ({ imageData, width, height }) => {
canvas.width = width;
canvas.height = height;
canvas.getContext("2d")?.putImageData(imageData, 0, 0);
});
stream = await navigator.mediaDevices.getUserMedia(constraints);
video.srcObject = stream;
video.addEventListener(
"loadeddata",
() =>
webcamRunning &&
handleEffectVideo(video, ({ imageData, width, height }) => {
canvas5.width = width;
canvas5.height = height;
canvas5.getContext("2d")?.putImageData(imageData, 0, 0);
})
);
- Init segmentation
import { imageSegmenter, init, handleEffectVideo, handleEffectImage } from "./lib/index";
await init();
- Blur background image
const image = <HTMLImageElement>document.getElementById("image");
canvas = <HTMLCanvasElement>document.getElementById("canvas");
handleEffectImage(canvas, image, { type: TYPE.BLUR });
node 18
git clone https://github.com/cuongle-hdwebsoft/blur-background-ts
npm i
nvm use
npm run dev
1. Why we cannot use putImage and blur effect together?
2. How can I mix 2 image together?
3. What is the core libray that I am using?
5. Image segmentation guide for web
6. Scaling an image to fit on canvas
8. CanvasRenderingContext2D: putImageData()
method
9. What is difference between @mediapipe/tasks-vision
and @mediapipe/selfie_segmentation
on npm?
10. What is the globalCompositeOperation
?
1. https://github.com/akhil-rana/virtual-bg
Contact to me through email cuong.leminh@hdwebsoft.dev or create an issue.