Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS How to Fire snd Event?

Luis Mb

New Coder
How to fire an Event when webcam recognize a specific color? I am working with tracking.js please take a look.. I try some like this:.


[CODE title="Fire event"]Var (r,g,b).
Var event-name = Event.event-name
If r>240; g<20; b<20. Function ()... fire('event_name');[/CODE]



Some idea??




<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>tracking.js - first tracking</title>
<script src="tracking-min.js"></script>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
</head>
<body>
<video id="myVideo" width="400" height="300" preload autoplay loop muted>
<source src='zuck.mp4' type="video/mp4" />
</video>
<button id='on' >Tracker on</button>
<button id='off'>Tracker off</button>
<script>
var _t = null;
$(document).ready(function() {
//var ct = tracking.ColorTracker
tracking.ColorTracker.registerColor('green', function(r, g, b) {
if (r == 0 && g == 250 && b == 0) {
return true;
}
return false;
});
tracking.ColorTracker.registerColor('black', function(r, g, b) {
if (r < 50 && g < 50 && b < 50) {
return true;
}
return false;
});
var colors = new tracking.ColorTracker(['magenta', 'cyan', 'yellow','green']);
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);
$('#on').click(function(e){
_t.run();
});
});
</script>
</body>
</html>
 
Hiya and welcome 🙂

please edit your post and put your code into a Code format by pressing this button
1618596995704.png
At the moment its quite hard to read.

PLEASE DO NOT OPEN ANY MORE THREADS, please edit your thread instead of duplicating the same thing over and over again
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom