老师问一下有没有什么方法能够只截取我下图中红色框中的图像,让openmv只对红框中的图像内容进行各种识别呢?是用roi还是其他什么?

有没有现有的例程啊?
ROI只能是矩形,不能是梯形。
@kidswong999 有获取矩形ROI区域的例程吗?
@kidswong999 老师你看一下,为什么我这边的ROI不起作用,是程序写得不对吗?
import sensor, image, time, math
ROI = [(50,100,50,80)]
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) # we run out of memory if the resolution is much bigger...
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
sensor.set_auto_whitebal(False) # must turn this off to prevent image washout...
clock = time.clock()
tag_families = 0
tag_families |= image.TAG16H5 # comment out to disable this family
tag_families |= image.TAG25H7 # comment out to disable this family
tag_families |= image.TAG25H9 # comment out to disable this family
tag_families |= image.TAG36H10 # comment out to disable this family
tag_families |= image.TAG36H11 # comment out to disable this family (default family)
tag_families |= image.ARTOOLKIT # comment out to disable this family
def family_name(tag):
if(tag.family() == image.TAG16H5):
return "TAG16H5"
if(tag.family() == image.TAG25H7):
return "TAG25H7"
if(tag.family() == image.TAG25H9):
return "TAG25H9"
if(tag.family() == image.TAG36H10):
return "TAG36H10"
if(tag.family() == image.TAG36H11):
return "TAG36H11"
if(tag.family() == image.ARTOOLKIT):
return "ARTOOLKIT"
for t in ROI:
while(True):
clock.tick()
img = sensor.snapshot()
for tag in img.find_apriltags(families=tag_families): # defaults to TAG36H11 without "families".
img.draw_rectangle(tag.rect(), color = (255, 0, 0))
img.draw_cross(tag.cx(), tag.cy(), color = (0, 255, 0))
print_args = (family_name(tag), tag.id(), (180 * tag.rotation()) / math.pi)
print("Tag Family %s, Tag ID %d, rotation %f (degrees)" % print_args)
print(clock.fps())img.find_apriltags(roi=(50,100,50,80))
@kidswong999 老师理论上可以用画矩形的这个函数把我想要的roi区域给框起来吗?我试了下面这个报错了。。
img.draw_rectangle(roi=(0,000,160,80), color = (0, 255, 0))@17826808312 不同的问题,单独发帖子。