eduardolundgren / tracking.js

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

Unexpected Feature Behavior #103

Open JohnMcLear opened 10 years ago

JohnMcLear commented 10 years ago

So I may be barking up the wrong tree here but I was using the feature detection just to do some basic edge detection of an object and I guess maybe I took the wrong approach to the problem but I expected the edges of the object to be "features" and not minor details inside of the feature.. I tried different thresholds to no avail..

http://i.imgur.com/k2V3Pz6.png <-- Note a lot of "Edges" are not shown as features despite the threshold being low (5).

eduardolundgren commented 10 years ago

Fast feature detector is meant to detect corners not edges. You may want to give a try with Sobel for detecting the edges:

tracking.Image.sobel(pixels, width, height);
eduardolundgren commented 10 years ago

Did Sobel work for what you were looking for?

JohnMcLear commented 10 years ago

Should this work?

      window.fastThreshold = 10;

      var doFindFeatures = function() {
        tracking.Fast.THRESHOLD = window.fastThreshold;
        context.drawImage(image, 0, 0, width, height);

        var imageData = context.getImageData(0, 0, width, height);
        var gray = tracking.Image.grayscale(imageData.data, width, height);
        var edges = tracking.Image.sobel(gray, width, height);

        for (var i = 0; i < edges.length; i += 2) {
          context.fillStyle = '#f00';
          context.fillRect(edges[i], edges[i + 1], 3, 3);
        }
      };

      doFindFeatures();

The output is just two lines across the screen ;\

JohnMcLear commented 10 years ago

@eduardolundgren any thoughts on this?

eduardolundgren commented 10 years ago

Hello @JohnMcLear, sorry for delaying this answer, I have been traveling in a project.

Hey @thiago-rocha, @pablocp could you help @JohnMcLear here?

alx-1 commented 8 years ago

@JohnMcLear, @eduardolundgren did you get it working? I get two similar lines, one horizontal and another oblique starting from the upper left corner of the image. wave

alx-1 commented 8 years ago

Here are the first few values of the array of pixels produced by sobel : 8.9442720413208,8.9442720413208, 8.9442720413208, 255, 5.656854152679443, 5.656854152679443, 5.656854152679443, 255, 17.262676239013672, 17.262676239013672, 17.262676239013672, 255, 18, 18, 18, 255, 3.1622776985168457... It might look like r,g,b,a values but I don't get the coords. It does explain the origin of those two lines. I suspect it is simply me not passing the imageData.data values it needs. Is there an example for the sobel function?

hydrococcous commented 7 years ago

Hello @JohnMcLear, @eduardolundgren, @JohnMcLear,

i have exactly the same problem. @JohnMcLear did you have a solution? Is there an example for the sobel function?