|
之前參加ican比賽,做了一個(gè)智能語音衣柜的項(xiàng)目,獲得了國家二等獎(jiǎng),電控部分完全是一個(gè)人完成的,外型是用3D打印的,用到了飛思卡爾的plc芯片,還有openmv,還有語音模塊,視頻里人丑忽略,大家多多執(zhí)教,謝謝,最后附上程序。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)
復(fù)制代碼
以上資料51hei提供下載(注意資料不全 僅供參考):
比賽程序.zip
(292.2 KB, 下載次數(shù): 9)
2020-4-1 16:45 上傳
點(diǎn)擊文件名下載附件
|
|