logo

为什么 img.draw_cross(r.cx(), r.cy())不能画出中心坐标 出现“r”中没有“cy和cx”

2019-10-07 16:49
0
qyn1

for r in img.find_rects(threshold = 30000, x_margin = 100, y_margin = 100, h_margin = 100,w_margin = 100,

r_min = 2, r_max = 100, r_step = 2):

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

#area1为识别到的矩形的区域,即外接矩形框

statistics = img.get_statistics(roi=area1)#像素颜色统计

print(statistics)

if 0<statistics.l_mode()<100 and 0<statistics.a_mode()<127 and 0<statistics.b_mode()<127:

img.draw_rectangle(r.x(), r.y(), r.h(),r.w(), color = (0, 255, 0))#识别到的红色圆形用绿色的圆框出来

img.draw_cross(r.cx(), r.cy(),color = (45, 65, 85), size = 10, thickness = 2)

为什么 img.draw_cross(r.cx(), r.cy(),color = (45, 65, 85), size = 10, thickness = 2)不能画出中心坐标

出现“r”中没有“cy和cx”

2019-10-08 00:32
I
网红小智智 星瞳科技

https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.image.html#id21

用

r.x()+r.w()/2

和

r.y()+r.h()/2

替代

2019-10-09 14:23
0
qyn1

@kidswong999 改完后出现 can't convert float to int 的错误这样该怎么纠正呢?

2019-10-10 14:47
I
网红小智智 星瞳科技

加一个int()

int(r.x()+r.w()/2)