资源简介
基于树莓派的动态图像对比(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)
评论
共有 条评论