javascript - Using background subtraction in a webcam-video feed in a HTML page -


i'm trying make prototype photobooth-ish setup interface being shown on html page. i've managed embed video within canvas element uses integrated/external webcam on computer show user's face/body depending on distance screen.

problem: need able eliminate background such person's face/body visible , rest transparent. need div tag housing overlayed on top of background such appears if person standing in front of device standing in different background setting (space,mountains,castles etc. illustrated on ui) in room. how can use image processing code within , how can achieve effect?

the code i'm working far:

<div id=outerdiv>             <video id="video" autoplay></video>             <canvas id="canvas" >                 <script>                     // put event listeners place                     window.addeventlistener("domcontentloaded", function() {                         // grab elements, create settings, etc.                         var canvas = document.getelementbyid("canvas"),                             context = canvas.getcontext("2d"),                             video = document.getelementbyid("video"),                             videoobj = { "video": true },                             errback = function(error) {                                 console.log("video capture error: ", error.code);                              };                          // put video listeners place                         if(navigator.getusermedia) { // standard                             navigator.getusermedia(videoobj, function(stream) {                                 video.src = stream;                                 video.play();                             }, errback);                         }                          else if(navigator.webkitgetusermedia) { // webkit-prefixed                             navigator.webkitgetusermedia(videoobj, function(stream){                                 video.src = window.webkiturl.createobjecturl(stream);                                 video.play();                             }, errback);                         }                     }, false);                 </script>             </canvas> </div> 

the effect (the image off internet , idea able detect person, eliminate background, replace black area transparent region - in live video feed being captured webcam):

intended effect background subtraction

any , guidance helpful!

i don't know if you've ever used "photobooth" app on mac os, similar operation. ask user first out of scene, way program gets true background image, think of calibration step. afterwards can true background subtraction. simplify problem opposed doing frame frame background subtractions. differences between subsequent frames, more difficult.

so if can "offline calibration" try that


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -