Page 1 of 1

color track

Posted: Mon Mar 05, 2018 3:58 am
by jisheng
hello,

I met a problem. I want to use the openmv to track the red color, but it doesnt work. How is blob.code() used? follows are the codes from example. is there anyone who can give me some advice? thanks a lot.

while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs(thresholds, pixels_threshold=100, area_threshold=100, merge=True):
if blob.code() ==(1 << 0): # r/g code == (1 << 1) | (1 << 0)
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
print(clock.fps())

Re: color track

Posted: Mon Mar 05, 2018 10:55 am
by kwagyeman
Hi, you have to provide the correct thresholds for the red color you wish to track. You can get these by using the threshold editor in OpenMV IDE.

As for how code() is used. Its an ID for the color of the blob found in the list of colors you passed for tracking.

Re: kwagyeman

Posted: Mon Mar 05, 2018 8:32 pm
by jisheng
for now, what I would like to do is, for example, traking the red color and if there is the red color in the image, i would like to return 1. Can this come true?

Re: color track

Posted: Mon Mar 05, 2018 10:10 pm
by kwagyeman
Yes, you just need to give the find_blobs() method the right color tracking thresholds.