logo

我在运行识别矩形的例程时,发现rect.x()为负值,这是为什么?

2019-08-01 00:50
P
Lzy

我在运行识别矩形的例程时,发现rect.x(),rect.y()为负值,这是为什么?

代码:

# Find Rects Example
#
# This example shows off how to find rectangles in the image using the quad threshold
# detection code from our April Tags code. The quad threshold detection algorithm
# detects rectangles in an extremely robust way and is much better than Hough
# Transform based methods. For example, it can still detect rectangles even when lens
# distortion causes those rectangles to look bent. Rounded rectangles are no problem!
# (But, given this the code will also detect small radius circles too)...

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())

运行结果:

1d3a2c40-cadd-425b-84b6-ddbba54ad838.png
2019-08-01 12:24
I
网红小智智 星瞳科技

我测试了代码,不是负数。

请提供你的硬件版本,固件版本,IDE版本。

2019-08-03 11:30
P
Lzy

@kidswong999 当我识别到多个举行时就会出现这负值

如图

0ca153d6-57df-4bbc-8e54-aed34ccb69bb.png

硬件版本:

e110e538-7a4d-40b2-ab29-0857b26bd754.jpg

是这个吧?

怎么看固件版本啊?

IDE版本

b33bfeeb-2e78-4e90-80dc-1f8e947c5a78.png
2019-08-03 20:39
I
网红小智智 星瞳科技

我这里挺正常的。

fce2abd1-ac51-46b5-84cf-620d8e9a0fad.png
2019-08-04 16:58
P
Lzy

@kidswong999 请问大佬知不知道产生负值的原因?