logo

下载代码后Open MV指示灯不亮不知道是否在工作,是代码问题吗

2024-04-16 14:40
9
gqmf
import sensor, image, time
from pyb import Pin
import math
threshold_index = 0
thresholds = [
    (34, 82, -32, -12, -13, 31),
]
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
clock = time.clock()
pin0 = Pin("P0", Pin.OUT_PP, Pin.PULL_NONE)
pin1 = Pin("P1", Pin.OUT_PP, Pin.PULL_NONE)
LED1 = Pin("P2", Pin.OUT_PP, Pin.PULL_NONE)
LED2 = Pin("P3", Pin.OUT_PP, Pin.PULL_NONE)
while True:
    clock.tick()
    img = sensor.snapshot()
    for blob in img.find_blobs(
            [thresholds[threshold_index]],
            pixels_threshold=200,
            area_threshold=200,
            merge=True,
        ):
        if blob.elongation() > 0.5:
            img.draw_edges(blob.min_corners(), color=(255, 0, 0))
            img.draw_line(blob.major_axis_line(), color=(0, 255, 0))
            img.draw_line(blob.minor_axis_line(), color=(0, 0, 255))
            img.draw_rectangle(blob.rect())
            img.draw_cross(blob.cx(), blob.cy())
            img.draw_keypoints(
                [(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20
            )
            if detected :

                pin1.value(1)
                LED1.value(1)
                time.sleep(30)
                pin1.value(0)
                LED1.value(0)

            else:
                pin0.value(1)
                LED2.value(1)
                time.sleep(30)

    print(clock.fps())
2024-04-18 20:11
I
网红小智智 星瞳科技

OpenMV的LED需要代码控制。你的代码不会亮灯。