eduardolundgren / tracking.js

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

Replace tracked color #224

Open MirkoAlo opened 7 years ago

MirkoAlo commented 7 years ago

Hello!

I Can replace the color tracked whit another color??

Thank you for this amazing library

yohanes-ai commented 7 years ago

Absolutely yes.

use registerColor function. Here is some snippet code.

tracking.ColorTracker.registerColor('yellow', function(r, g, b) {
    var threshold = 50,
      dx = r - 255,
      dy = g - 255,
      dz = b - 0;

    if ((r - b) >= threshold && (g - b) >= threshold) {
      return true;
    }
    return dx * dx + dy * dy + dz * dz < 10000;
  });
revolunet commented 7 years ago

solved ?

MirkoAlo commented 7 years ago

Hi Julien!

No i can't solve it, i tracked the color but i don't know i can replace it whit another color... Do you have an example to show me??

Thank you so much for the support,

Mirko


Da: Julien Bouquillon notifications@github.com Inviato: domenica 2 luglio 2017 00:01:33 A: eduardolundgren/tracking.js Cc: MirkoAlo; Author Oggetto: Re: [eduardolundgren/tracking.js] Replace tracked color (#224)

solved ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/eduardolundgren/tracking.js/issues/224#issuecomment-312457900, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARYew_9MHgVWXDIFyKid6IYXFs7k8neYks5sJsG9gaJpZM4Nnh4y.

yohanes-ai commented 7 years ago

Did you mean replacing color, let say color in some part in your image?

MirkoAlo commented 7 years ago

Yes, I'd like that the background of an image, black for example, begin White...


Da: NPE notifications@github.com Inviato: domenica 2 luglio 2017 18:09:46 A: eduardolundgren/tracking.js Cc: MirkoAlo; Author Oggetto: Re: [eduardolundgren/tracking.js] Replace tracked color (#224)

Did you mean replacing color, let say color in some part in your image?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/eduardolundgren/tracking.js/issues/224#issuecomment-312500768, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARYew6u12IWXTrwVE2OmcNfgSAZU1dxdks5sJ8DKgaJpZM4Nnh4y.

djipco commented 7 years ago

@JhonImmanuel Would you care to elaborate? I'm trying to add your registerColor() snippet but it does not work. In fact, I've had no success at all with registerColor() so far.

I'm using it with a webcam feed and, as far as I can tell, the function registered with registerColor() is not even being called... Does it need to be called in a specific order?

Do you perhaps have a full example of using registerColor() with a webcam somewhere? There must be something I'm doing wrong but I have no clue what...

djipco commented 7 years ago

Ok, I got it working. The documentation is kinda vague as to the fact that you first need to register the color to a name and then create a new ColorTracker using that name as a parameter...