同时识别圆形和矩形为啥通电后不好使 啊
-
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) # grayscale is faster (160x120 max on OpenMV-M7) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() while(True): clock.tick() img = sensor.snapshot() # 下面的`threshold`应设置为足够高的值,以滤除在图像中检测到的具有 # 低边缘幅度的噪声矩形。最适用与背景形成鲜明对比的矩形。 for r in img.find_rects(threshold = 10000): img.draw_rectangle(r.rect(), color = (255, 0, 0)) for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0)) print(r) img1 = sensor.snapshot().lens_corr(1.8) for c in img1.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10, r_min = 2, r_max = 100, r_step = 2): area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r()) #area为识别到的圆的区域,即圆的外接矩形框 statistics = img1.get_statistics(roi=area)#像素颜色统计 print(statistics) #(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。 #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。 if 0<statistics.l_mode()<100 and 0<statistics.a_mode()<127 and 0<statistics.b_mode()<127:#if the circle is red img.draw_rectangle(area, color = (255, 255, 255))#识别到的红色圆形用红色的圆框出来 elif 30<statistics.l_mode()<100 and -64<statistics.a_mode()<-8 and -32<statistics.b_mode()<32:#if the circle is red img.draw_rectangle(area, color = (255, 255, 255))#识别到的红色圆形用红色的圆框出来 elif 0<statistics.l_mode()<15 and 0<statistics.a_mode()<-40 and -80<statistics.b_mode()<-20:#if the circle is red img.draw_rectangle(area, color = (255, 255, 255))#识别到的红色圆形用红色的圆框出来 print("FPS %f" % clock.fps())
-
什么叫做不好使?
具体什么错误?你想解决什么问题?