导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. 搜索

    高级搜索

    搜索子版块
    保存设置 清除设置
    共 499 条结果匹配 "sensor",(耗时 0.02 秒)

    RT1062中machine模块配置外部中断的wake参数等于machine.SLEEP时,提示没有这个参数

    0_1740736044396_49f75744-d2ba-473b-a8cb-7e10ec98c295-image.png

    import sensor
    import time
    import machine
    
    def ExtInt_IRQHandler(pin):
        Red.on()
        time.sleep_ms(5000)
        Red.off()
    
    sensor.reset()  # Reset and initialize the sensor.
    sensor.set_pixformat(sensor.RGB565)  # Set pixel format to RGB565 (or GRAYSCALE)
    sensor.set_framesize(sensor.VGA)  # Set frame size to QVGA (320x240)
    sensor.skip_frames(time=2000)  # Wait for settings take effect.
    clock = time.clock()  # Create a clock object to track the FPS.
    Pin_Ext = machine.Pin("P7",machine.Pin.IN,pull = machine.Pin.PULL_UP)# 初始化外部中断
    Pin_Ext.irq(ExtInt_IRQHandler,trigger = machine.Pin.IRQ_RISING,wake=machine.SLEEP)#初始化外部中断,配置唤醒源为Pin
    Red = machine.LED("LED_RED")
    
    machine.lightsleep()
    
    while True:
        clock.tick()  # Update the FPS clock.
        img = sensor.snapshot()  # Take a picture and return the image.
        img.lens_corr(strength=1.8,zoom=1.0)
        print(clock.fps())  # Note: OpenMV Cam runs about half as fast when connected
        # to the IDE. The FPS should increase once disconnected.
    
    

    0_1740736094565_39d53133-925b-4d7f-a62d-6957a783899a-image.png

    G
    发布在 OpenMV Cam

    图像识别几秒之后灯会变成红色,然后就锁定啦?

    OpenMV IDE 4.7.0,固件版本 4.6.20OpenMVr2
    代码:# Hello World Example

    Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

    import sensor
    import time
    from machine import UART, LED

    sensor.reset() # Reset and initialize the sensor.
    sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
    sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
    sensor.skip_frames(time=2000) # Wait for settings take effect.
    clock = time.clock() # Create a clock object to track the FPS.

    black = (32, 100, -128, 127, -128, 127)
    uart = UART(1, 9600)

    LED("LED_RED").on()

    while uart.any()==0:
    continue

    LED("LED_BLUE").on()
    LED("LED_GREEN").on()

    while True:
    img = sensor.snapshot() # Take a picture and return the image.
    blobs = img.find_blobs([black], invert=True, roi = [0,100,320,48])

    if len(blobs) == 1:
        img.draw_rectangle([0,100,320,48])
        img.draw_rectangle(blobs[0][0:4], color = (0, 255, 0))
        uart.write('#'+str(blobs[0].cx())+'$')
        print('#'+str(blobs[0].cx())+'$')
    elif len(blobs) == 0:
        uart.write('S')
        print('S')
        LED("LED_GREEN").off()
        while True:
            continue

    Q
    发布在 OpenMV Cam

    怎么能减小灰度图与彩图之间的切换频率?

    import sensor, image, math,pyb

    sensor.reset()
    sensor.set_framesize(sensor.QVGA)
    while(True):
    sensor.set_pixformat(sensor.GRAYSCALE)
    for i in range(10):
    img=sensor.snapshot()
    for j in range(100):
    x=(pyb.rng()%(2img.width()))-(img.width()//2)
    y=(pyb.rng()%(2
    img.height()))-(img.height()//2)
    img.set_pixel(x,y,255)
    sensor.set_pixformat(sensor.RGB565)
    for i in range(10):
    img=sensor.snapshot()
    for j in range(100):
    x=(pyb.rng()%(2img.width()))-(img.width()//2)
    y=(pyb.rng()%(2
    img.height()))-(img.height()//2)
    img.set_pixel(255,255,255)

    惠
    发布在 OpenMV Cam

    请问外部中断的函数具体是如何实现的啊,要实现的就是通过外部中断改变全局变量的值,返回给主程序中,让其执行不同的内容?

    import sensor, image, pyb,  micropython, utime
    
    
    micropython.alloc_emergency_exception_buf(100)
    from pyb import Pin
    
    global bull
    bull=1
    
    def callback(line):
        global bull
        bull=bull+1
        extint.disable()
    
    extint = pyb.ExtInt(Pin('P7'), pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_UP, callback)
    
    
    while(bull==1):
        utime.sleep(1)
        print(bull)
        utime.sleep(1)
    
    if bull==2:
        utime.sleep(1)
        print(bull)
        extint.enable()
        utime.sleep(1)
     
    
    if bull==3:
        utime.sleep(1)
        print(bull)
        extint.enable()
        utime.sleep(1)
    
    if(True):
        print('Hello,World')
        utime.sleep_ms(500) 
        print(bull)
    
    
    
    
    

    G
    发布在 OpenMV Cam

    openmv调用外部中断为什么没有反应?

    @kidswong999 新代码如下
    from pyb import Pin, ExtInt
    import sensor, image, time,pyb,micropython
    micropython.alloc_emergency_exception_buf(100)

    sensor.reset()
    sensor.set_pixformat(sensor.RGB565)
    sensor.set_framesize(sensor.QVGA)
    sensor.skip_frames(time = 2000)

    clock = time.clock()

    def callback(line):
    ExtInt.disable()
    print("line =", line)
    ExtInt.enable()
    extint = pyb.ExtInt(Pin('P0'), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, callback)
    while(True):
    clock.tick()
    img = sensor.snapshot()

    出现错误MemoryError: memory allocation failed, heap is locked
    您看是什么原因啊?

    I
    发布在 OpenMV Cam

    MemoryError:Out of normal MicroPython Heap Memory!

    0_1546910281324_3e5eac07-c939-42b6-82b7-f032cb555f7b-image.png

    
    import time, sensor, image
    from image import SEARCH_EX, SEARCH_DS
    
    sensor.reset()
    sensor.set_contrast(1)
    sensor.set_gainceiling(16)
    sensor.set_framesize(sensor.QQVGA)
    sensor.set_pixformat(sensor.GRAYSCALE)
    
    
    templates = ["/ren.pgm", "/zhi.pgm", "/chu.pgm"]
    
    clock = time.clock()
    
    while (True):
        clock.tick()
        img = sensor.snapshot()
    
        for tem in templates:
            template = image.Image(tem)
            r = img.find_template(template, 0.70, step=4, search=SEARCH_EX)
            if r:
                img.draw_rectangle(r)
                print(tem)
    
        print(clock.fps())
    
    

    求助大佬 谢谢

    么
    发布在 OpenMV Cam

    自动增益为什么有时候会失效

    enable_lens_corr = False # turn on for straighter lines...

    import sensor, image, time
    sensor.set_auto_gain(False)
    sensor.reset()
    sensor.set_pixformat(sensor.RGB565) # grayscale is faster
    sensor.set_framesize(sensor.QQVGA)
    sensor.skip_frames(time = 2000)
    clock = time.clock()

    min_degree = 0
    max_degree = 179

    while(True):
    clock.tick()
    img = sensor.snapshot()
    if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...

    for l in img.find_lines(threshold = 1000, theta_margin = 30, rho_margin = 30):
        if (min_degree <= l.theta()) and (l.theta() <= max_degree):
            img.draw_line(l.line(), color = (255, 0, 0))
            print(l)
    
    
    print("FPS %f" % clock.fps())

    1
    发布在 OpenMV Cam

    set_windowing设置ROI后显示出来的ROI区域扭曲?

    import sensor, image, time,pyb
    
    ROI=(50,70,390,340)
    
    sensor.reset() # 初始化摄像头
    sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
    sensor.set_framesize(sensor.VGA)
    sensor.set_windowing(ROI)
    sensor.skip_frames(10) # 跳过10帧,使新设置生效
    sensor.set_auto_whitebal(False)# Create a clock object to track the FPS.
    
    clock = time.clock()
    
    while(True):
        img = sensor.snapshot()         # Take a picture and return the image.
    

    0_1557973876090_捕获.PNG

    I
    发布在 OpenMV Cam

    为什么运行这个程序,IDE没有报错,但是却自动断开连接

    import sensor, image, time
    
    sensor.reset()
    sensor.set_pixformat(sensor.GRAYSCALE) # or RGB565.
    sensor.set_framesize(sensor.QVGA)
    sensor.skip_frames(time = 2000)
    sensor.set_auto_gain(False) # must be turned off for color tracking
    sensor.set_auto_whitebal(False) # must be turned off for color tracking
    clock = time.clock()
    
    #threshold =[42, 66, -29, 7, 3, 38]
    
    while(True):
        clock.tick()
        img = sensor.snapshot()
        histogram = img.get_histogram()#得到直方图
        Thresholds = histogram.get_threshold()#得到最佳阈值
        l = Thresholds.l_value()
        a = Thresholds.a_value()
        b = Thresholds.b_value()
        print(Thresholds)
    

    B
    发布在 OpenMV Cam

    有办法知道脱机运行程序跑飞错误的原因吗?

    但是在循环中用 try catch的话有几率出现IDE的上的停止按钮也无法中断程序
    要改程序只能格式化。
    比如下面这段:

    import sensor, image, time
    
    sensor.reset()
    sensor.set_pixformat(sensor.RGB565)
    sensor.set_framesize(sensor.QVGA)
    sensor.skip_frames(time = 2000)
    
    clock = time.clock()
    
    while(True):
        try:
            clock.tick()
            img = sensor.snapshot()
            print(clock.fps())
        except:
            pass
    

    T
    发布在 OpenMV Cam
    • 1
    • 2
    • 46
    • 47
    • 48
    • 49
    • 50
    • 48 / 50