color track

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())

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.

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?

Yes, you just need to give the find_blobs() method the right color tracking thresholds.