specific black spot

Store Forums Video Experimenter General Discussion specific black spot

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #461
    xtoragu
    Member

    I am trying to use the black spot following example, but I do not understand completely how is is that the darkest spot is identified? Is this done through voltage comparators?
    I would like to concentrate on one black spot only at a time. If another dark spot is identified in the video image, the bounding box will enclose both dark elements. If someone could guide me, I would be very greatful.

    Thanks and great weekend to all.

    Xto

    #1086
    Michael
    Keymaster

    Yes, the Arduino’s voltage comparator is used to determine whether a pixel is black or white. The object tracking example is very simple and only looks for the bounding box around the area with dark (or light) pixels. To identify separate individual spots, you’ll have to write some more sophisticated code to process the frame buffer.

    #1087
    xtoragu
    Member

    Thanks for the feedback. I actually would like to achieve the boxin of 2 or 3 regions where the most black pixels are grouped. Is it in the tvout.cpp or the video_gen.cpp where the conditions for the voltage comparator are set? I think I saw it in the tvout.cpp. Some few hints on where to look would help me get started. First i need to understand the code much better and how the white pixels and dark ones are defined. After achieving it, ill post in for others to use. it might be handy. thanks for the support michael.

    xto

    #1088
    Michael
    Keymaster

    The analog comparator threshhold is controlled with the long-stemmed potentiometer on the board. The code for finding the bounding box of a spot is not in the library. It’s in the sketch for this project:

    http://nootropicdesign.com/projectlab/2011/03/20/arduino-computer-vision/

    It’s just a simple algorithm for finding the first row, last row, first column, and last column with white (or black if you invert) pixels. Study this code.

      // compute bounding box
    minX = W;
    minY = H;
    maxX = 0;
    maxY = 0;
    boolean found = 0;
    for(int y=0;y for(int x=0;x c = tv.get_pixel(x,y);
    if (c == 1) {
    found = true;
    if (x < minX) {
    minX = x;
    }
    if (x > maxX) {
    maxX = x;
    }
    if (y < minY) {
    minY = y;
    }
    if (y > maxY) {
    maxY = y;
    }
    }
    }
    }

    // draw bounding box
    tv.fill(0);
    if (found) {
    tv.draw_line(minX, minY, maxX, minY, 1);
    tv.draw_line(minX, minY, minX, maxY, 1);
    tv.draw_line(maxX, minY, maxX, maxY, 1);
    tv.draw_line(minX, maxY, maxX, maxY, 1);
    sprintf(s, "%d, %d", ((maxX+minX)/2), ((maxY+minY)/2));
    tv.print(0, 0, s);
    }

    If you want to do something more sophisticated, like identify more than one spot, then you need to write more sophisticated code than this.

    #1090
    xtoragu
    Member

    if anyone interested ill share soon my code to identify two black or bright spots. still some minor things to correct

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.