之前参加ican比赛,做了一个智能语音衣柜的项目,获得了国家二等奖,电控部分完全是一个人完成的,外型是用3D打印的,用到了飞思卡尔的plc芯片,还有openmv,还有语音模块,视频里人丑忽略,大家多多执教,谢谢,最后附上程序。B站有视频:https://www.bilibili.com/video/BV1qQ4y1M739
Python源程序如下:
- from pid import PID
- from pyb import Servo
- import sensor, image, time,pyb
- from pyb import UART
- pan_pid = PID(p=0.075, i=0, imax=90)
- tilt_pid = PID(p=0.05, i=0, imax=90)
- s1 = Servo(1)
- tilt_servo=Servo(2)
- s3 = Servo(3)
- sensor.reset()
- led1 = pyb.LED(1)
- led2 = pyb.LED(2)
- led3 = pyb.LED(3)
- sensor.set_contrast(3)
- sensor.set_gainceiling(16)
- sensor.set_framesize(sensor.QVGA)
- sensor.set_windowing((320, 240))
- sensor.set_pixformat(sensor.GRAYSCALE)
- sensor.skip_frames(time = 2000)
- sensor.set_auto_gain(False, value=100)
- led1.on()
- led2.on()
- led3.on()
- def draw_keypoints(img, kpts):
- if kpts:
- print(kpts)
- img.draw_keypoints(kpts)
- img = sensor.snapshot()
- time.sleep(1000)
- kpts1 = None
- K=5000
- clock = time.clock()
- i = 0
- while (True):
- s3.angle(-60)
- b = 1500 + i
- s1.pulse_width(b)
- i = i+40
- if(i>1000):
- i = 0
- clock.tick()
- img = sensor.snapshot()
- if (kpts1 == None):
- kpts1 = img.find_keypoints(max_keypoints=150, threshold=7, scale_factor=1.2)
- draw_keypoints(img, kpts1)
- else:
- kpts2 = img.find_keypoints(max_keypoints=150, threshold=7, normalized=True)
- if (kpts2):
- img = sensor.snapshot()
- match = image.match_descriptor(kpts1, kpts2, threshold=85)
- if (match.count()>10):
- while(1):
- kpts2 = img.find_keypoints(max_keypoints=150, threshold=7, normalized=True)
- img = sensor.snapshot()
- img.draw_rectangle(match.rect())
- img.draw_cross(match.cx(), match.cy(), size=10)
- s1.pulse_width(b)
- time.sleep(2000)
- s3.angle(-20)
- time.sleep(2000)
- s1.angle(-180)
- time.sleep(2000)
- s3.angle(-60)
- time.sleep(200000)
复制代码
以上资料51hei提供下载(注意资料不全 仅供参考):
比赛程序.zip
(292.2 KB, 下载次数: 9)
|