logo

这个是什么错误呢???

2019-08-26 10:17
9
dx1i
ff108ba3-6edd-4919-9386-fad5e4780c0a.png
2019-08-26 13:23
I
网红小智智 星瞳科技

如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片

2019-08-26 15:29
9
dx1i

这个是全部代码了,我只是想在矩形识别的基础上进行像素统计,进行颜色识别

import sensor, image, time

from pyb import UART

import json

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` below should be set to a high enough value to filter out noise

# rectangles detected in the image which have low edge magnitudes. Rectangles

# have larger edge magnitudes the larger and more contrasty they are...

blos= img.find_rects(threshold = 12000)

if blos:

print('sum')

for r in blos:

area=(r.x(),r.y(),r.w(),r.h())

img.draw_rectangle(r.rect(), color = (255, 0, 0))

statistics=img.get_statistics(roi=area)

for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))

if 0<statistics.l_mode<127 and 0<statistics.a_mode<127 and 0<statistics.b_mode<127:

print(r)

uart.write('red')

2019-08-28 14:15
I
网红小智智 星瞳科技

函数或者方法的话,需要用括号调用。

I
网红小智智 星瞳科技

statistics.l_mode()

2019-09-05 16:47
I
网红小智智 星瞳科技

@dx1i 不同的问题,单独发帖子。