color track

General discussion about topics related to OpenMV.
jisheng
Posts: 23
Joined: Wed Apr 12, 2017 9:42 pm

color track

Postby jisheng » Mon Mar 05, 2018 3:58 am

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())
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: color track

Postby kwagyeman » Mon Mar 05, 2018 10:55 am

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.
Nyamekye,
jisheng
Posts: 23
Joined: Wed Apr 12, 2017 9:42 pm

Re: kwagyeman

Postby jisheng » Mon Mar 05, 2018 8:32 pm

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?
User avatar
kwagyeman
Posts: 1771
Joined: Sun May 24, 2015 2:10 pm

Re: color track

Postby kwagyeman » Mon Mar 05, 2018 10:10 pm

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

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest