c=1
while c<=6:
#print(type(s))
a=s.replace('+','')
#print(a)
if c==1:
num=a[0]
print(num)
if c==2:
num=a[1]
print(num)
if c==3:
num=a[2]
print(num)
if c==4:
num=a[3]
print(num)
if c==5:
num=a[4]
print(num)
if c==6:
num=a[5]
print(num)
clock = time.clock()
img = sensor.snapshot().lens_corr(1.8)
blobs = img.find_blobs([red_threshold_01], pixels_threshold=100, area_threshold=100, merge=True, margin=10);
blobs1 = img.find_blobs([green_threshold_01], pixels_threshold=100, area_threshold=100, merge=True, margin=10);
blobs2 = img.find_blobs([blue_threshold_01], pixels_threshold=100, area_threshold=100, merge=True, margin=10);
cx=0;cy=0;cx1=0;cy1=0;cx2=0;cy2=0;
for R in img.find_rects(threshold = 10000):
for p in R.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
area = (R.x(),R.y(),R.w(),R.h())
statistics = img.get_statistics(roi=area)#像素颜色统计
#print(statistics)
if num=='1': #red
while(1):
print('red')
if 0<statistics.l_mode()<100 and 7<statistics.a_mode()<127 and -128<statistics.b_mode()<127:#若矩形是红色
img.draw_rectangle(R.x(), R.y(), R.w(),R.h(), color = (255, 0, 0))
if blobs: #定位
#如果找到了目标颜色
for blob in blobs:
img.draw_cross(blob[5], blob[6]) # cx, cy
img.draw_cross(160, 120) # 在中心点画标记
#在目标颜色区域的中心画十字形标记
cx=blob[5];
cy=blob[6];
img.draw_line((160,120,cx,cy), color=(127));
img.draw_string(cx, cy, "(%d, %d)"%(cx,cy), color=(127));
word=print(cx,cy)
#uart.write(cx,cy)
word_0='word'
time.sleep_ms(5000)
H
hn3i 发布的帖子
-
在使用for遍历之前加上while之后帧缓存区卡死,程序仍在进行?