openmv循迹方式

1.摄像头模拟灰度传感器

判断偏移程度方法

A.利用在摄像头某位置设置多个roi,在roi区域内使用find_blobs函数,返回面积,检测其里面的阈值有多少是有大面积红色的,在这个方块里面还可以加上函数筛除只占了点边的红色方块(彩色灰度都适用)

# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor
import time,image

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

while True:
    clock.tick()  # Update the FPS clock.
    img = sensor.snapshot()  # Take a picture and return the image.
    #(0, 14)
    kk=[(25,120,30,30),(55,120,30,30),(85,120,30,30),(115,120,30,30),(145,120,30,30),(175,120,30,30),(205,120,30,30),(235,120,30,30),(265,120,30,30),(295,120,30,30)]
    C=0
    for i in kk[0:10]:
        img.draw_rectangle(i,color=(255,255,255))
        C=C+1
        A=img.find_blobs([(0, 4, -49, 25, -76, 69)],roi=i)
        E=0
        F=0
        if  A:
            for D in A:
                E=D.area()+E
                F=F+1
        if  E:
            if E/F>400 :
                print(C)
 

B.可以运用image.get_statistics(roi=你设定的几个区域)看roi区域内的像素平均值有没有在你想要检测的颜色范围之中(只适用于灰度模式)

# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor
import time,image

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

while True:
    clock.tick()  # Update the FPS clock.
    img = sensor.snapshot()  # Take a picture and return the image.
    #(0, 14)
    kk=[(25,120,30,30),(55,120,30,30),(85,120,30,30),(115,120,30,30),(145,120,30,30),(175,120,30,30),(205,120,30,30),(235,120,30,30),(265,120,30,30),(295,120,30,30)]
    C=0
    for i in kk[0:10]:
        img.draw_rectangle(i,color=(255,255,255))
        C=C+1
        A=img.get_statistics(roi=i)
        if  A:
            B=A.mean()
            if 70<B<80 :
                print(C)
 

2.线性回归

3.利用找方块,取他们的均值

  • 14
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

广药门徒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值