Store › Forums › Video Experimenter › General Discussion › specific black spot
- This topic has 4 replies, 2 voices, and was last updated 12 years, 10 months ago by xtoragu.
-
AuthorPosts
-
February 4, 2012 at 5:17 pm #461xtoraguMember
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
February 4, 2012 at 5:40 pm #1086MichaelKeymasterYes, 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.
February 5, 2012 at 4:17 am #1087xtoraguMemberThanks 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
February 5, 2012 at 3:35 pm #1088MichaelKeymasterThe 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;yfor(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.
February 14, 2012 at 6:46 am #1090xtoraguMemberif anyone interested ill share soon my code to identify two black or bright spots. still some minor things to correct
-
AuthorPosts
- You must be logged in to reply to this topic.