eduardolundgren / tracking.js

A modern approach for Computer Vision on the web
http://trackingjs.com
Other
9.43k stars 1.44k forks source link

First example on trackingjs.com simply doesn’t work #392

Open cfcoderatcodefactory opened 4 years ago

cfcoderatcodefactory commented 4 years ago

Under the title/subheading «Step 2: Choose what you want to play with», this code is supposed to «request your camera and track magenta, cyan and yellow colors that appear in front of it.»

However, nothing happens when I load this page in Firefox or Chrome.

Anyone?

Code: <!doctype html>

tracking.js - first tracking
yegdynrs commented 3 years ago

1:在tracking.js中修改element.src = window.URL.createObjectURL(stream);为element.srcObject = stream;

tracking.initUserMedia_ = function(element, opt_options) { window.navigator.getUserMedia( { video: true, audio: !!(opt_options && opt_options.audio) }, function(stream) { try { //window.URL.createObjectURL(stream)会报错; //element.src = window.URL.createObjectURL(stream); element.srcObject = stream; } catch (err) { element.src = stream; } }, function() { throw Error("Cannot capture user camera."); } ); };

2369257907 commented 2 years ago

@yegdynrs Thank you for your guide.However ,though I have change tracking.js with your advice ,things doesn't become better.The camera still can't work and the page of the first example is blank. I wonder if there anything that i need to do to solve the problem. Looking forward to your reply.