ML Library
Maintained by Crejo.Fun
1. Motion Detection
const getEnergyScore = ml.motionDetector.createEnergyScoreGetter({
videoElement: webcamVideo.current,
canvasElementHelper: canvas1.current,
canvasElementDisplay: canvas2.current,
thresh: 150,
alpha: 0.5
})
const id = window.setInterval(() => {
const score = getEnergyScore()
console.log('score:', score)
}, 32);
See full template for react app here in codesandbox.
2. Body Detection
const detector = await ml.poseDetector.createDetector(webcamVideo.current);
....
const isCorrectFrame = await ml.poseDetector.isBodyInFrame(detector, webcamVideo.current);
See full template for react app here in codesandbox.
3. Haar Cascade Detection
Note: This implementation needs to be optimized
const detect = ml.haarDetector.createHaarDetector({
videoElement: webcamVideo.current,
canvasElementDisplay: canvasDispaly.current
})
const id = window.setInterval(() => {
detect()
}, 32);
Temporary template can be found here in codesandbox