0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何利用樹莓派3B實(shí)現(xiàn)智能門禁對講系統(tǒng)的設(shè)計(jì)

科技觀察員 ? 來源:hackster.io ? 作者:hackster.io ? 2022-04-05 16:45 ? 次閱讀

該項(xiàng)目為實(shí)時(shí)系統(tǒng),僅允許通過授權(quán)/受邀人員,使用人臉識別或NFC卡。

工作步驟:

人臉接近對講機(jī)

看著相機(jī)

系統(tǒng)將臉與授權(quán)人進(jìn)行比較

如果找到對應(yīng)的數(shù)據(jù),那么門就會打開,允許一個(gè)人可以進(jìn)入

還有另一種通過方式;

持有通行卡的人將其放置到RFID位置,如果在其數(shù)據(jù)庫中找到此卡的代碼,門就會打開

準(zhǔn)備

繼電器連接

將繼電器連接到RPI3。在我的例子中,我使用GPIO12引腳作為數(shù)據(jù),5v作為電源,你可以選擇任何GND。

您可以使用shell腳本測試中繼,只需創(chuàng)建一個(gè)簡單的sh腳本:

poYBAGJIDOqAMCZOAAAUcxybbTw407.png

粘貼下面的代碼并運(yùn)行它。

腳本代碼:

poYBAGJIDOWAfW10AAF1vuJZEgc269.png

相機(jī)連接

連接相機(jī)模塊并在raspi-config中啟用它:

從終端打開工具:raspi-config

pYYBAGJIDOCAR_HCAAAGo2w90aE708.png

選擇Enablecamera并點(diǎn)擊Enter,然后轉(zhuǎn)到,系統(tǒng)Finish將提示您重新啟動。

要測試系統(tǒng)是否已安裝并正常工作,請嘗試以下命令:

pYYBAGJIDNyALjSKAAAHUV7a238706.png

LED連接

將您的LED連接到您想要的任何GPIO+GND。在我的例子中,我將GPIO16用于綠色LED,將GPIO26用于紅色。完成后,測試:

為綠色和紅色LED創(chuàng)建2個(gè)簡單的Python腳本,內(nèi)容如下:

綠燈.py

pYYBAGJIDNiAQB4xAAA93WzYn9M176.png

紅色led2.py

pYYBAGJIDNSABSJNAAJyJUfD-cE476.png

接著就可以進(jìn)行測試了。如果LED發(fā)光,則一切正常。

poYBAGJIDNCAa2UWAAAQmhDok2s551.png

人臉識別腳本

pip3使用(或用于Python2)從pypi安裝此模塊:pip2

poYBAGJIDMyAREptAAASV9IQrmI149.png

例如,在 Documents 中創(chuàng)建目錄“pic”和“unknown”,并在其中放置一些您認(rèn)識的人的面部照片。就我而言,它是(“/home/pi/Documents/pic/”)和(“/home/pi/Documents/unknown/”)。

使用以下代碼創(chuàng)建一個(gè) python 腳本:

import face_recognition
import picamera
import numpy as np
import os
camera = picamera.PiCamera()
camera.resolution = (320, 240)
output = np.empty((240, 320, 3), dtype=np.uint8)
print("Loading known face image(s)")
ep_image = face_recognition.load_image_file("/home/pi/Documents/pic/ep.jpg")
ep_face_encoding = face_recognition.face_encodings(ep_image)[0]
vl_image = face_recognition.load_image_file("/home/pi/Documents/pic/vl.jpg")
vl_face_encoding = face_recognition.face_encodings(vl_image)[0]
face_locations = []
face_encodings = []
while True:
print("Capturing image.")
camera.capture(output, format="rgb")
face_locations = face_recognition.face_locations(output)
print("Found {} faces in image.".format(len(face_locations)))
face_encodings = face_recognition.face_encodings(output, face_locations)
for face_encoding in face_encodings:
match = face_recognition.compare_faces([ep_face_encoding,vl_face_encoding], face_encoding)
name = ""
os.system("python /home/pi/led2.py &")
import time
date_string = time.strftime("%Y-%m-%d-%H:%M:%S")
camera.capture("/home/pi/Documents/unknown/image-" + date_string + ".jpg")

測試

pYYBAGJIDMWAedH6AAAJl_PaUBM655.png

RFID連接

引腳:

pYYBAGJIDMGAerplAAD66c-bwo0765.png

我們需要這個(gè)以將我們的RFID模塊連接到RaspberryPi1。

ready:

poYBAGJIDL2AesjJAABkkvyaapk312.png

read.py :當(dāng)腳本找到授權(quán)卡時(shí),它在遠(yuǎn)程 RPI 3 上打開用戶圖片(運(yùn)行 LED 腳本),然后開門。

import MFRC522
import signal
import os
continue_reading = True
MIFAREReader = MFRC522.MFRC522()
cardA = [46,44,187,26,163]
cardB = [176,203,130,124,133]
cardC = [20,38,121,207,132]
def end_read(signal, frame):
global continue_reading
continue_reading = False
print "Ctrl+C captured, ending read."
MIFAREReader.GPIO_CLEEN()
signal.signal(signal.SIGINT, end_read)
while continue_reading:
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
if status == MIFAREReader.MI_OK:
print "Card detected"
(status,backData) = MIFAREReader.MFRC522_Anticoll()
if status == MIFAREReader.MI_OK:
print "Card read UID: "+str(backData[0])+","+str(backData[1])+","+str(backData[2])+","+str(backData[3])+","+str(backData[4])
if backData == cardA:
print "Evghenii"
os.system("sshpass -p *password* ssh root@10.0.0.60 fbi -T 1 -d /dev/fb1 -noverbose /home/pi/Documents/pic/ep.jpg")
os.system("sshpass -p *password* ssh root@10.0.0.60 /home/pi/Documents/open.sh 2>/dev/null")
# os.system("sshpass -p *password* ssh root@10.0.0.60 sleep 2")
os.system("sshpass -p *password* ssh root@10.0.0.60 killall fbi")
elif backData == cardB:
print "Vlad"
os.system("sshpass -p *password* ssh root@10.0.0.60 fbi -T 1 -d /dev/fb1 -noverbose /home/pi/Documents/pic/vl.jpg")
os.system("sshpass -p *password* ssh root@10.0.0.60 /home/pi/Documents/open.sh 2>/dev/null")
# os.system("sshpass -p *password* ssh root@10.0.0.60 sleep 2")
os.system("sshpass -p *password* ssh root@10.0.0.60 killall fbi")
elif backData == cardC:
print "is Card C"
else:
print "wrong Card"
os.system("sshpass -p *password* ssh root@10.0.0.60 /home/pi/led2.py 2>/dev/null")

  • 使用這個(gè)例子:

poYBAGJIDLeAfcu9AAA4FhFgnQQ774.png

按鈕 + 通訊
#!/usr/bin/python
import RPi.GPIO as GPIO
from subprocess import call
from datetime import datetime
import time
import os
shutdownPin = 29
shutdownMinSeconds = 5
# button debounce time in seconds
debounceSeconds = 0.01
GPIO.setmode(GPIO.BOARD)
GPIO.setup(shutdownPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
buttonPressedTime = None
def buttonStateChanged(pin):
global buttonPressedTime
if not (GPIO.input(pin)):
# button is down
if buttonPressedTime is None:
buttonPressedTime = datetime.now()
else:
# button is up
if buttonPressedTime is not None:
elapsed = (datetime.now() - buttonPressedTime).total_seconds()
buttonPressedTime = None
if elapsed >= shutdownMinSeconds:
call(['shutdown', '-r', 'now'], shell=True)
elif elapsed >= debounceSeconds:
os.system("bash /home/pi/timed.sh")
# subscribe to button presses
GPIO.add_event_detect(shutdownPin, GPIO.BOTH, callback=buttonStateChanged)
while True:
# sleep to reduce unnecessary CPU usage
time.sleep(5)

功能.sh

#!/bin/bash
sshpass -p password ssh epogonii@ipadress -p1337 notify-send -i /usr/share/icons/gnome/32x32/actions/ring2.png Smart-Intercom Guest_at_the_door
DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh --hide-pointer -x -q -D 5 -B black -F /home/pi/doorway.png &
sh /home/pi/Documents/open.sh > log.out 2> /dev/null
DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority xdotool key "x"
sh /home/pi/tgphoto.sh FaceRec /var/www/html/last.jpg > log.out 2> /dev/null

pYYBAGJIDK-AO9UEAAE3wrUuV0w710.png

此處為智能對講增加了按鈕。它會將您的最后一張照片發(fā)送給通訊機(jī)器人,并向Ubuntu桌面PC發(fā)送通知。

poYBAGJIDKuAe3h4AADeZMsaQ3I474.png

為按鈕添加計(jì)時(shí)

為了通過按鈕在特定時(shí)間禁用入口,我制作了以下bash腳本:

poYBAGJIDKWATOopAABSuTRooYo121.png

action.sh-早上7點(diǎn)到晚上19??點(diǎn)開門

error.sh-在晚上19??點(diǎn)到早上7點(diǎn)之間停止使用,顯示限制圖像error.sh腳本

pYYBAGJIDKCAaWeJAABxRytDlY4834.png
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • 樹莓派
    +關(guān)注

    關(guān)注

    116

    文章

    1679

    瀏覽量

    105252
  • 智能門禁系統(tǒng)
    +關(guān)注

    關(guān)注

    0

    文章

    15

    瀏覽量

    5036
  • 樹莓派3B+
    +關(guān)注

    關(guān)注

    0

    文章

    3

    瀏覽量

    744
收藏 人收藏

    評論

    相關(guān)推薦

    樹莓型號3B+與型號3B比一比

    B+有什么新特點(diǎn)? 看看最新的Pi和舊一代的比較。 在這篇文章中,我們先來看看最新的樹莓型號3B +以及一些新的和改進(jìn)的功能,還有更多的細(xì)節(jié)尚未公布。 請注意,這篇文章中使用的
    的頭像 發(fā)表于 04-13 09:48 ?12.6w次閱讀

    樹莓3b,為什么是32位的armv7

    3b是32位(圖上這個(gè)getconf是硬件還是軟件位數(shù)),硬件是32位的?3b的處理器寫著是bcm2837,系統(tǒng)里看是arm7這是正常
    發(fā)表于 10-01 22:10

    請問樹莓3B有沒有wifi模塊的能支持自建AP么?

    幫會員提問,請大家?guī)蛶退?b class='flag-5'>樹莓3B有沒有wifi模塊的。能支持自建AP么?樹莓3B有沒有wif
    發(fā)表于 06-09 15:12

    請問樹莓3B/3B+和4B如何安裝OpenCV?

    樹莓3B/3B+和4B安裝OpenCV教程
    發(fā)表于 11-05 07:17

    怎樣利用樹莓3B去控制28步進(jìn)電機(jī)?

    ,樓主自行購買了28步進(jìn)電機(jī)及相應(yīng)的驅(qū)動器,完成了對步進(jìn)電機(jī)的控制。硬件設(shè)備:樹莓3B 28步進(jìn)電機(jī)及其驅(qū)動 12V開關(guān)電源...
    發(fā)表于 07-08 07:39

    樹莓3b的工作電流不足會有什么影響

    樹莓3b最好的工作電流是多少?樹莓3b的工作電流不足會有什么影響?
    發(fā)表于 10-11 08:16

    樹莓3B的硬件配置有哪些

    1、樹莓3B(Raspberry Pi 3 型號 B SBC)硬件配置Broadcom BCM2837 芯片組,運(yùn)行頻率 1.2 GHz
    發(fā)表于 01-19 06:55

    樹莓3B的硬件資源詳細(xì)介紹免費(fèi)下載

    本文檔的主要內(nèi)容詳細(xì)介紹的是樹莓3B的硬件資源詳細(xì)介紹免費(fèi)下載。
    發(fā)表于 10-26 08:00 ?66次下載
    <b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3B</b>的硬件資源詳細(xì)介紹免費(fèi)下載

    樹莓3B的電路原理圖免費(fèi)下載

    本文檔的主要內(nèi)容詳細(xì)介紹的是樹莓3B的電路原理圖免費(fèi)下載。
    發(fā)表于 04-22 08:00 ?121次下載
    <b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3B</b>的電路原理圖免費(fèi)下載

    樹莓3B上運(yùn)行64位系統(tǒng)的測評詳細(xì)說明

    今天,我們團(tuán)隊(duì)感受了一下在樹莓3B 的主板上運(yùn)行64bit 系統(tǒng)的感覺!那種感覺您如果有幸感受的話,您一定會說:這才是我要的樹莓
    發(fā)表于 11-21 16:17 ?12次下載

    樹莓3b調(diào)mjpg-streamer庫實(shí)現(xiàn)監(jiān)控功能

    功能。一、準(zhǔn)備工作1.需要的模塊和單片機(jī)今天我們需要的是樹莓3b和一個(gè)攝像頭,將其連接好是這樣的然后我們將利用SSH方式,登錄上樹莓
    發(fā)表于 12-22 18:47 ?6次下載
    <b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3b</b>調(diào)mjpg-streamer庫<b class='flag-5'>實(shí)現(xiàn)</b>監(jiān)控功能

    OpenHarmony Dev-Board-SIG專場:OpenHarmony樹莓3B移植技術(shù)分享

    OpenHarmony Dev-Board-SIG專場:OpenHarmony樹莓3B移植技術(shù)分享
    的頭像 發(fā)表于 12-28 14:47 ?2127次閱讀
    OpenHarmony Dev-Board-SIG專場:OpenHarmony<b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3B</b>移植技術(shù)分享

    OpenHarmony Dev-Board-SIG專場:開發(fā)板選型—為什么選擇樹莓3B

    OpenHarmony Dev-Board-SIG專場:開發(fā)板選型—為什么選擇樹莓3B
    的頭像 發(fā)表于 12-28 14:51 ?2101次閱讀
    OpenHarmony Dev-Board-SIG專場:開發(fā)板選型—為什么選擇<b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3B</b>

    rt-smart移植分析:從樹莓3b入手

    移植rt-smart到最新的板子上具體需要注意哪些細(xì)節(jié),哪些才是移植rt-smart的關(guān)鍵點(diǎn)?本文從樹莓3b上移植rt-smart的角度,從頭分析rt-sm...
    發(fā)表于 01-25 18:48 ?0次下載
    rt-smart移植分析:從<b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3b</b>入手

    樹莓3B/4B散熱風(fēng)扇帽

    電子發(fā)燒友網(wǎng)站提供《樹莓3B/4B散熱風(fēng)扇帽.zip》資料免費(fèi)下載
    發(fā)表于 07-25 14:31 ?4次下載
    <b class='flag-5'>樹莓</b><b class='flag-5'>派</b><b class='flag-5'>3B</b>/4<b class='flag-5'>B</b>散熱風(fēng)扇帽