資源簡介
基于樹莓派的動態圖像對比(py3_object_detection.py)
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
“““
Created?on?Thu?May??7?17:26:11?2020
@author:?fd
Desc:
????this?is?a?demo?for?detecting?moving?objects.?
????the?algorithm?of?frame?differences?is?used.
“““
import?cv2
import?uuid
import?RPI.GPIO?as?GPIO
import?time
??????
????
if?__name__?==?‘__main__‘:????
????led_channel?=?21
????switch_channel?=?10????
????GPIO.setmode(GPIO.BOARD)
????GPIO.setup(led_channel?GPIO.OUT)
????GPIO.setup(switch_channel?GPIO.IN?pull_up_down=GPIO.PUD_UP)
????
????cap?=?cv2.VideoCapture(0)
????frame_width?=?int(cap.get(cv2.CAP_PROP_frame_WIDTH))
????frame_height?=?int(cap.get(cv2.CAP_PROP_frame_HEIGHT))
????
????for?i?in?range(5):
????????GPIO.output(led_channel?GPIO.HIGH)
????????time.sleep(0.2)
????????GPIO.output(led_channel?GPIO.LOW)
????????time.sleep(0.2)
????????
????intervals?=?5
????try:
????????while?True:????????????
????????????if?GPIO.input(switch_channel)?==?GPIO.LOW:
????????????????#?lighten?LED
????????????????GPIO.output
- 上一篇:Python調用第三方API換臉
- 下一篇:自動化測試(基于pytest)
評論
共有 條評論