Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cfcoderatcodefactory opened this issue May 5, 2020 · 2 comments
Open

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

cfcoderatcodefactory opened this issue May 5, 2020 · 2 comments

Comments

@cfcoderatcodefactory
Copy link

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>

<title>tracking.js - first tracking</title> <script src="../build/tracking-min.js"></script> <script> var colors = new tracking.ColorTracker(['magenta', 'cyan', 'yellow']);

colors.on('track', function(event) {
if (event.data.length === 0) {
// No colors were detected in this frame.
} else {
event.data.forEach(function(rect) {
console.log(rect.x, rect.y, rect.height, rect.width, rect.color);
});
}
});

tracking.track('#myVideo', colors);
</script>

@yegdynrs
Copy link

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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants