以下代码为矩形识别代码,如何反馈矩形的中心位置(坐标)具体是多少呀?
-
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` 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... 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) print("FPS %f" % clock.fps())
请在这里粘贴代码
-
请大佬们帮忙看一下,十分感谢!
-
https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.image.html#rect
根据文档,就是
中心x坐标 = r.x() + r.w()/2 中心y坐标 = r.y() + r.h()/2