资源简介

该文件包括三部分,一个是openmv的官方云台三维模型,可直接打印,一个是openmv的程序,该程序可同时识别三个颜色,本程序中同时识别了红绿蓝,识别后返回颜色顺序,通过串口通信给stm32主控,并在LCD屏幕上显示识别结果,第三部分就是stm32的程序,用于接收mv返回的数据

资源截图

代码片段和文件信息

import sensor image time

from pid import PID
from pyb import Servo

pan_servo=Servo(1)
tilt_servo=Servo(2)

red_threshold  = (13 49 18 61 6 47)

pan_pid = PID(p=0.07 i=0 imax=90) #脱机运行或者禁用图像传输,使用这个PID
tilt_pid = PID(p=0.05 i=0 imax=90) #脱机运行或者禁用图像传输,使用这个PID
#pan_pid = PID(p=0.1 i=0 imax=90)#在线调试使用这个PID
#tilt_pid = PID(p=0.1 i=0 imax=90)#在线调试使用这个PID

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(10) # Let new settings take affect.
sensor.set_auto_whitebal(False) # turn this off.
clock = time.clock() # Tracks FPS.

def find_max(blobs):
    max_size=0
    for blob in blobs:
        if blob[2]*blob[3] > max_size:
            max_blob=blob
            max_size = blob[2]*blob[3]
    return max_blob


while(True):
    clock.tick() # Track elapsed milliseconds between snapshots().
    img = sensor.snapshot() # Take a picture and return the image.

    blobs = img.find_blobs([red_threshold])
    if blobs:
        max_blob = find_max(blobs)
        pan_error = max_blob.cx()-img.width()/2
        tilt_error = max_blob.cy()-img.height()/2

        print(“pan_error: “ pan_error)

        img.draw_rectangle(max_blob.rect()) # rect
        img.draw_cross(max_blob.cx() max_blob.cy()) # cx cy

        pan_output=pan_pid.get_pid(pan_error1)/2
        tilt_output=tilt_pid.get_pid(tilt_error1)
        print(“pan_output“pan_output)
        pan_servo.angle(pan_servo.angle()+pan_output)
        tilt_servo.angle(tilt_servo.angle()-tilt_output)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-05-09 10:24  MV云台\
     文件     1736934  2019-08-06 14:30  MV云台\OpenMV-Pan-Tilt-master.zip
     目录           0  2020-05-09 10:24  MV云台\OpenMV-Pan-Tilt-master\
     文件        1065  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\LICENSE
     目录           0  2020-05-09 10:24  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\
     目录           0  2020-05-09 10:24  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\
     文件       10417  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\gerber.zip
     文件       40886  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.brd
     文件         841  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.dri
     文件       11055  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GBL
     文件        2638  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GBO
     文件         756  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GBS
     文件        1036  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.gpi
     文件       12117  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GTL
     文件       11274  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GTO
     文件         105  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GTP
     文件         756  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.GTS
     文件       39534  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.sch
     文件         451  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\eagle\servo.TXT
     目录           0  2020-05-09 10:24  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\img\
     文件      286618  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\img\1.jpg
     文件      333728  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\img\2.jpg
     文件      310308  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\img\3.jpg
     目录           0  2020-05-09 10:24  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\
     文件      155381  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\base.SLDPRT
     文件      114552  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\head.SLDPRT
     文件      105327  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\left.SLDPRT
     文件      158623  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\pan_tilt.SLDASM
     文件      126853  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\right.SLDPRT
     文件      139213  2018-04-16 22:45  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\solidworks\rotate.SLDPRT
     目录           0  2020-05-09 10:24  MV云台\OpenMV-Pan-Tilt-master\pan-tilt\src\
............此处省略228个文件信息

评论

共有 条评论