一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

電子發(fā)燒友App

硬聲App

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

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

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>使用BOLT的實(shí)時(shí)安全系統(tǒng)

使用BOLT的實(shí)時(shí)安全系統(tǒng)

2022-11-23 | zip | 0.18 MB | 次下載 | 免費(fèi)

資料介紹

描述

一、簡(jiǎn)介:-

歡迎大家來(lái)我的項(xiàng)目。首先,我想說(shuō)我們生活在互聯(lián)網(wǎng)世界中,開發(fā)和實(shí)踐新想法比以前更容易。我們可以很容易地開發(fā)出任何可以為我們提供更好的生活水平,也可以幫助社會(huì)并給世界帶來(lái)巨大影響的模型。

如今,許多行業(yè)和許多人都大量使用安全系統(tǒng)來(lái)獲得更好的安全性。由于對(duì)高度穩(wěn)定的安全系統(tǒng)的需求不斷增加,許多公司準(zhǔn)備投資這個(gè)市場(chǎng)以提高可靠性和可擴(kuò)展性。在這里,我的項(xiàng)目是創(chuàng)建一個(gè)安全系統(tǒng),該系統(tǒng)主要包含兩個(gè)不同的模塊,基于哪個(gè)系統(tǒng)工作:

這兩個(gè)模塊將由 BOLT IoTArduino 設(shè)備控制,當(dāng)兩個(gè)模塊都正確識(shí)別一個(gè)人時(shí),它允許他們鎖定或解鎖任何設(shè)備。在這里,我正在開發(fā)一個(gè)可以在任何設(shè)備上實(shí)現(xiàn)的原型,即鎖定或解鎖桌面上的任何門或文件夾或任何用戶或客戶想要的任何東西。由于我們的安全系統(tǒng)包含鎖定和解鎖部分;對(duì)于解鎖部分,我將使用一個(gè) LED,當(dāng)兩個(gè)模塊完美識(shí)別一個(gè)人時(shí)它會(huì)發(fā)光,這意味著系統(tǒng)已解鎖,否則將保持關(guān)閉狀態(tài)。并且為了顯示鎖定部分,當(dāng)系統(tǒng)解鎖時(shí),即當(dāng)LED發(fā)光時(shí),系統(tǒng)再次識(shí)別人,如果所有模塊都識(shí)別人,則系統(tǒng)將被鎖定并且它可以用Led顯示,即 它將被關(guān)閉。在這里,我們還將為用戶創(chuàng)建一個(gè) GUI,以決定他們是要鎖定還是解鎖系統(tǒng)。GUI 中有兩個(gè)按鈕供用戶選擇是否要解鎖系統(tǒng)或鎖定系統(tǒng)。可以用任何東西代替 LED,但代碼和實(shí)現(xiàn)保持不變。此外,如果用戶試圖解鎖一個(gè)已經(jīng)打開的設(shè)備,那么系統(tǒng)將提示該設(shè)備已經(jīng)解鎖,并保持鎖定機(jī)制。

在這里,很多人都會(huì)有一個(gè)問(wèn)題,為什么我們需要再次識(shí)別鎖定系統(tǒng)的人。因此,我這樣做是為了提供一些額外的安全性,以便在實(shí)施該系統(tǒng)的任何設(shè)備上,用戶都可以在整個(gè)過(guò)程中感到安全,并且可以相信沒(méi)有人可以在未經(jīng)他許可的情況下解鎖或鎖定任何設(shè)備。

似乎是一個(gè)令人興奮的項(xiàng)目,對(duì)!所以讓我們開始吧。

注意:-我目前沒(méi)有伺服電機(jī),所以我使用 LED 來(lái)證明打開和關(guān)閉的目的。

2. 基本軟件設(shè)置:

2.1 窗口:

由于我們?cè)?Windows 上執(zhí)行所有操作,因此我們需要在繼續(xù)之前對(duì)其進(jìn)行設(shè)置。首先,我們應(yīng)該在我們的系統(tǒng)上運(yùn)行 python,如果沒(méi)有,下載并在您的系統(tǒng)中安裝 python。之后,我們需要安裝 bolt iot 包來(lái)使用 pip 命令訪問(wèn) windows 中的 bolt 設(shè)備。

pip install boltiot

完成此操作后,我們還需要安裝其他包來(lái)運(yùn)行我們的代碼,即 dlib 包、人臉識(shí)別包、termcolor、matplotlib、opencv 和 sklearn 包。可以使用 pip 命令安裝所有軟件包,后跟安裝和軟件包名稱。例如:

pip install dlib

用戶還必須在您的系統(tǒng)中安裝 pyqt 工具。這個(gè) pyqt 工具支持 python,將用于為用戶創(chuàng)建 GUI。

2.2 Bolt-IoT API 密鑰

在這里,Bolt-IoT 用于管理所有任務(wù),如果有任何入侵者,向用戶或所有者發(fā)送短信。它也有自己的云平臺(tái)。

pYYBAGN6xlyAZyV0AAA95397JKw666.png
圖。1
?

要獲取 Bolt API 密鑰,請(qǐng)單擊菜單中的 API,您將找到您的 API 密鑰。您還可以重新生成 API 密鑰或復(fù)制生成的密鑰并妥善保管以供日后使用。還要保存您將在主窗口中看到的唯一 Bolt id。這兩個(gè)數(shù)據(jù)稍后可用于向用戶發(fā)送短信或通過(guò) Internet 訪問(wèn)您的 Bolt 設(shè)備。

2.3 暮光之城:

Twilio 用于從遠(yuǎn)程服務(wù)器向所有者發(fā)送短信。因此,當(dāng)任何入侵者試圖訪問(wèn)安全系統(tǒng)時(shí),我們將使用此服務(wù)通知安全系統(tǒng)的所有者。我們可以利用 python 對(duì)設(shè)備進(jìn)行編程,借助 Bolt 設(shè)備和 Twilio 帳戶的 API 密鑰向用戶發(fā)送短信。您可以訪問(wèn)https://www.twilio.com/開設(shè) Twilio 帳戶

您可以使用帳戶 SID 和帳戶令牌等 Twilio 內(nèi)容,通過(guò)儀表板上顯示的手機(jī)號(hào)碼通過(guò) Internet 發(fā)送短信。

pYYBAGN6xl6ACUunAACcnXJGl4c714.png
Twilio 儀表板(圖 - 2)
?

上圖 - 2 代表 Twilio 儀表板,您可以從中獲取通過(guò) Internet 向所需人員發(fā)送短信所需的信息。

3. 開發(fā)軟件:

由于我們的軟件太大,我們將把它分解成不同的模塊,逐步了解每個(gè)模塊是如何構(gòu)建的以及它們是如何工作的。

3.1 人臉識(shí)別模塊:

在這里,對(duì)于人臉識(shí)別,我將使用 opencv、深度學(xué)習(xí)和 python。在這里,我們不是試圖輸出圖像的單個(gè)標(biāo)簽,而是輸出一個(gè)實(shí)值特征向量。對(duì)于我們正在創(chuàng)建的 dlib 面部識(shí)別模塊,輸出特征向量是 128-d,即用于量化面部的 128 個(gè)實(shí)數(shù)值的列表。使用三元組訓(xùn)練網(wǎng)絡(luò)所以在這里,我們需要大量的數(shù)據(jù)集,其中包含將被允許訪問(wèn)安全系統(tǒng)的人的圖像。然后將使用 SVM 方法對(duì)這些數(shù)據(jù)集中的圖像進(jìn)行訓(xùn)練。我們將在項(xiàng)目的主要部分中使用這些經(jīng)過(guò)訓(xùn)練的數(shù)據(jù)集來(lái)識(shí)別人臉。讓我們看一個(gè)示例圖像:

poYBAGN6xmGATQjqAAB6UQn8qns270.png
圖 - 圖 3
?

通過(guò)深度度量學(xué)習(xí)進(jìn)行面部識(shí)別涉及“三元組訓(xùn)練步驟”。三元組由 3 個(gè)獨(dú)特的人臉圖像組成——3 個(gè)中的 2 個(gè)是同一個(gè)人。神經(jīng)網(wǎng)絡(luò)為 3 個(gè)人臉圖像中的每一個(gè)生成一個(gè) 128 維向量。對(duì)于同一個(gè)人的兩張人臉圖像,我們通過(guò)距離度量調(diào)整神經(jīng)網(wǎng)絡(luò)權(quán)重以使向量更接近。

這里我們向網(wǎng)絡(luò)提供三張圖片:

  • 其中兩個(gè)圖像是同一個(gè)人的示例面孔。
  • 第三張圖片是我們數(shù)據(jù)集中的一張隨機(jī)人臉,與其他兩張圖片不是同一個(gè)人。

作為示例,讓我們?cè)俅慰紤]上圖 -3,其中我們提供了三張圖像:一張是 Chad Smith,兩張是 Will Ferrell。我們的網(wǎng)絡(luò)對(duì)人臉進(jìn)行量化,為每個(gè)人臉構(gòu)建 128 維嵌入(量化)。從那里開始,一般的想法是我們將調(diào)整我們的神經(jīng)網(wǎng)絡(luò)的權(quán)重,以便兩個(gè) Will Ferrel 的 128 維測(cè)量值將彼此更接近并且遠(yuǎn)離 Chad Smith 的測(cè)量值。

我們的人臉識(shí)別模塊基于 CNN(卷積神經(jīng)網(wǎng)絡(luò))。

poYBAGN6xmOAAhLQAAAlLVQfjnc451.png
數(shù)據(jù)(圖 - 4)
?

如上圖所示,您可以看到我創(chuàng)建的包含三個(gè)文件夾的數(shù)據(jù)集。每個(gè)文件夾都包含將被訓(xùn)練的那些人的一些圖像。

pYYBAGN6xmWAX26PAAAo2vHiKu4757.png
圖 - 圖 5
?

上圖 - 5 顯示了用于創(chuàng)建人臉識(shí)別系統(tǒng)的文件。encodes_faces python 文件包含用于訓(xùn)練數(shù)據(jù)集的代碼。正確訓(xùn)練數(shù)據(jù)集后,它將創(chuàng)建一個(gè)encodings.pickle文件,其中包含每個(gè)人臉的人臉結(jié)構(gòu)和關(guān)鍵值,用于驗(yàn)證實(shí)時(shí)人臉并提供授權(quán)訪問(wèn)等。每當(dāng)我們想要識(shí)別新面孔以授予權(quán)限時(shí),recognize_faces_image python 文件都會(huì)運(yùn)行。它將創(chuàng)建新驗(yàn)證人臉的 128 維向量,并將其與經(jīng)過(guò)訓(xùn)練的數(shù)據(jù)集文件匹配以授予權(quán)限。下面提供了訓(xùn)練數(shù)據(jù)集的完整代碼。

# import the necessary packages
from imutils import paths
import face_recognition
import argparse
import pickle
import cv2
import os

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--dataset", required=True,
	help="path to input directory of faces + images")
ap.add_argument("-e", "--encodings", required=True,
	help="path to serialized db of facial encodings")
ap.add_argument("-d", "--detection-method", type=str,,
	help="face detection model to use: either `hog` or `cnn`")
args = vars(ap.parse_args())

# grab the paths to the input images in our dataset
print("[INFO] quantifying faces...")
imagePaths = list(paths.list_images(args["dataset"]))

# initialize the list of known encodings and known names
knownEncodings = []
knownNames = []

# loop over the image paths
for (i, imagePath) in enumerate(imagePaths):
	# extract the person name from the image path
	print("[INFO] processing image {}/{}".format(i + 1,
		len(imagePaths)))
	name = imagePath.split(os.path.sep)[-2]

	# load the input image and convert it from RGB (OpenCV ordering)
	# to dlib ordering (RGB)
	image = cv2.imread(imagePath)
	rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

	# detect the (x, y)-coordinates of the bounding boxes
	# corresponding to each face in the input image
	boxes = face_recognition.face_locations(rgb,
		model=args["detection_method"])

	# compute the facial embedding for the face
	encodings = face_recognition.face_encodings(rgb, boxes)

	# loop over the encodings
	for encoding in encodings:
		# add each encoding + name to our set of known names and
		# encodings
		knownEncodings.append(encoding)
		knownNames.append(name)

# dump the facial encodings + names to disk
print("[INFO] serializing encodings...")
data = {"encodings": knownEncodings, "names": knownNames}
f = open(args["encodings"], "wb")
f.write(pickle.dumps(data))
f.close()

一旦我們訓(xùn)練了我們的數(shù)據(jù)集,它將如上所述創(chuàng)建.pickle 文件。代碼中給出的注釋將指導(dǎo)我們出于什么目的使用了代碼或語(yǔ)句的哪一部分。

pYYBAGN6xmeAdFuqAAAqu1Qu_JM468.png
Training_Image(圖 - 6)
?

上圖 6 顯示了訓(xùn)練圖像的過(guò)程。這將需要很長(zhǎng)時(shí)間,具體取決于您的數(shù)據(jù)集圖像大小以及數(shù)據(jù)集中的圖像總數(shù)。接下來(lái),我們將運(yùn)行識(shí)別人臉代碼以在 python 中識(shí)別人臉。

# import the necessary packages
import face_recognition
import argparse
import pickle
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-e", "--encodings", required=True,
	help="path to serialized db of facial encodings")
ap.add_argument("-i", "--image", required=True,
	help="path to input image")
ap.add_argument("-d", "--detection-method", type=str,,
	help="face detection model to use: either `hog` or `cnn`")
args = vars(ap.parse_args())

# load the known faces and embeddings
print("[INFO] loading encodings...")
data = pickle.loads(open(args["encodings"], "rb").read())

# load the input image and convert it from BGR to RGB
image = cv2.imread(args["image"])
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# detect the (x, y)-coordinates of the bounding boxes corresponding
# to each face in the input image, then compute the facial embeddings
# for each face
print("[INFO] recognizing faces...")
boxes = face_recognition.face_locations(rgb,
	model=args["detection_method"])
encodings = face_recognition.face_encodings(rgb, boxes)

# initialize the list of names for each face detected
names = []

# loop over the facial embeddings
for encoding in encodings:
	# attempt to match each face in the input image to our known
	# encodings
	matches = face_recognition.compare_faces(data["encodings"],
		encoding)
	name = "Unknown"

	# check to see if we have found a match
	if True in matches:
		# find the indexes of all matched faces then initialize a
		# dictionary to count the total number of times each face
		# was matched
		matchedIdxs = [i for (i, b) in enumerate(matches) if b]
		counts = {}
		# loop over the matched indexes and maintain a count for
		# each recognized face face
		for i in matchedIdxs:
			name = data["names"][i]
			counts[name] = counts.get(name, 0) + 1
			print (counts)
		key_max = max(counts.keys(), key=(lambda k: counts[k]))
		print (counts[key_max])
		
		# determine the recognized face with the largest number of
		# votes (note: in the event of an unlikely tie Python will
		# select first entry in the dictionary)
		
		a = counts[key_max]-8 #adjust this number 8 as per ur dataset
		if (a==0):
			name = max(counts, key=counts.get)
		else:
			name = "Unknown"
		
	# update the list of names
	names.append(name)

# loop over the recognized faces
for ((top, right, bottom, left), name) in zip(boxes, names):
	# draw the predicted face name on the image
	cv2.rectangle(image, (left, top), (right, bottom), (0, 255, 0), 2)
	y = top - 15 if top - 15 > 15 else top + 15
	cv2.putText(image, name, (left, y), cv2.FONT_HERSHEY_SIMPLEX,
		0.75, (0, 255, 0), 2)

# show the output image
cv2.imshow("Image", image)
cv2.waitKey(0)

訓(xùn)練數(shù)據(jù)后,我們將僅在項(xiàng)目中使用 .pickle 文件和識(shí)別人臉 python 文件以供進(jìn)一步使用。代碼中給出的注釋將幫助我們更好地理解代碼。

3.2 音頻識(shí)別:

在這里,在音頻識(shí)別方面,我們遵循了與 Shazam 大致相同的概念。在這里,我們還將存儲(chǔ)一些我們想要驗(yàn)證音頻的用戶的 mp3。然后,我們將訓(xùn)練這些 mp3 文件來(lái)存儲(chǔ) mp3 文件的一些指紋,例如音高、音調(diào)等。在這里,我們按照傅里葉變換算法來(lái)完成任務(wù)。一旦我們訓(xùn)練并記錄了一些數(shù)據(jù)集的指紋以用于匹配目的,我們將運(yùn)行我們的主要代碼來(lái)識(shí)別來(lái)自麥克風(fēng)的音頻并將其與我們訓(xùn)練的數(shù)據(jù)集進(jìn)行匹配,如果匹配,我們將提供授權(quán)訪問(wèn)。

首先,我們將創(chuàng)建并存儲(chǔ)一些需要匹配語(yǔ)音的用戶的 mp3 文件。

然后我們將使用下面提供的代碼從每個(gè)音頻文件中識(shí)別或收集一些重要的指紋。

import os
from termcolor import colored
import libs.fingerprint as fingerprint
from libs.config import get_config
from libs.db_sqlite import SqliteDatabase
from libs.reader_file import FileReader

if __name__ == '__main__':
    config = get_config()
    db = SqliteDatabase()
    path = "mp3/"
    # fingerprint all files in a directory
    for filename in os.listdir(path):
        if filename.endswith(".mp3"):
            reader = FileReader(path + filename)
            audio = reader.parse_audio()

            song = db.get_song_by_filehash(audio['file_hash'])
            song_id = db.add_song(filename, audio['file_hash'])

            msg = ' * %s %s: %s' % (
                colored('id=%s', 'white', attrs=['dark']),  # id
                colored('channels=%d', 'white', attrs=['dark']),  # channels
                colored('%s', 'white', attrs=['bold'])  # filename
            )
            print(msg % (song_id, len(audio['channels']), filename))

            if song:
                hash_count = db.get_song_hashes_count(song_id)

                if hash_count > 0:
                    msg = '   already exists (%d hashes), skip' % hash_count
                    print(colored(msg, 'red'))

                    continue

            print(colored('   new song, going to analyze..', 'green'))

            hashes = set()
            channel_amount = len(audio['channels'])

            for channeln, channel in enumerate(audio['channels']):
                msg = '   fingerprinting channel %d/%d'
                print(colored(msg, attrs=['dark']) % (channeln + 1, channel_amount))

                channel_hashes = fingerprint.fingerprint(channel, Fs=audio['Fs'],
                                                         plots=config['fingerprint.show_plots'])
                channel_hashes = set(channel_hashes)

                msg = '   finished channel %d/%d, got %d hashes'
                print(colored(msg, attrs=['dark']) % (channeln + 1, channel_amount, len(channel_hashes)))

                hashes |= channel_hashes

            msg = '   finished fingerprinting, got %d unique hashes'

            values = []
            for hash, offset in hashes:
                values.append((song_id, hash, offset))

            msg = '   storing %d hashes in db' % len(values)
            print(colored(msg, 'green'))

            db.store_fingerprints(values)

    print('end')

一旦收集了所有文件的指紋,它將創(chuàng)建一個(gè)config.json文件,其中包含所有音頻的所有指紋。

注意:- 注釋有助于更好地理解代碼的不同部分。

poYBAGN6xmmAYwHjAAEaLSN_Tgs718.png
圖 - 圖 7
?

上圖 7 顯示了從我們數(shù)據(jù)集中存儲(chǔ)的每個(gè)音頻中收集指紋的片段。接下來(lái),我們將運(yùn)行另一個(gè) python 代碼來(lái)識(shí)別通過(guò)麥克風(fēng)輸入的實(shí)時(shí)聲音。下面的代碼片段說(shuō)明了用于該目的的代碼。

import argparse
import sys
from argparse import RawTextHelpFormatter
from itertools import zip_longest as izip_longest
from termcolor import colored
import libs.fingerprint as fingerprint
from libs.config import get_config
from libs.db_sqlite import SqliteDatabase
from libs.reader_microphone import MicrophoneReader
from libs.visualiser_console import VisualiserConsole as visual_peak
from libs.visualiser_plot import VisualiserPlot as visual_plot

def align_matches(matches):
    diff_counter = {}
    largest = 0
    largest_count = 0
    song_id = -1

    for tup in matches:
        sid, diff = tup

        if diff not in diff_counter:
            diff_counter[diff] = {}

        if sid not in diff_counter[diff]:
            diff_counter[diff][sid] = 0

        diff_counter[diff][sid] += 1

        if diff_counter[diff][sid] > largest_count:
            largest = diff
            largest_count = diff_counter[diff][sid]
            song_id = sid

    songM = db.get_song_by_id(song_id)

    nseconds = round(float(largest) / fingerprint.DEFAULT_FS *
                     fingerprint.DEFAULT_WINDOW_SIZE *
                     fingerprint.DEFAULT_OVERLAP_RATIO, 5)

    return {
        "SONG_ID": song_id,
        "SONG_NAME": songM[1],
        "CONFIDENCE": largest_count,
        "OFFSET": int(largest),
        "OFFSET_SECS": nseconds
    }


def grouper(iterable, n, fillvalue=None):
    args = [iter(iterable)] * n
    return (filter(None, values)
            for values in izip_longest(fillvalue=fillvalue, *args))


def find_matches(samples, Fs=fingerprint.DEFAULT_FS):
    hashes = fingerprint.fingerprint(samples, Fs=Fs)
    return return_matches(hashes)


def return_matches(hashes):
    mapper = {}
    for hash, offset in hashes:
        mapper[hash.upper()] = offset
    values = mapper.keys()

    for split_values in map(list, grouper(values, 1000)):
        # @todo move to db related files
        query = """
    SELECT upper(hash), song_fk, offset
    FROM fingerprints
    WHERE upper(hash) IN (%s)
  """
        query = query % ', '.join('?' * len(split_values))

        x = db.executeAll(query, split_values)
        matches_found = len(x)
        print(x)

        if matches_found > 0:
            msg = '   ** found %d hash matches (step %d/%d)'
            print(colored(msg, 'green') % (
                matches_found,
                len(split_values),
                len(values)
            ))
        else:
            msg = '   ** not matches found (step %d/%d)'
            print(colored(msg, 'red') % (len(split_values), len(values)))

        for hash_code, sid, offset in x:
            # (sid, db_offset - song_sampled_offset)
            print(sid)
            print(sum(list(offset)))
            print(offset)
            print(mapper[hash_code])
            print(-(list(offset)-mapper[hash_code]))
            yield (sid, sum(list(offset)) - mapper[hash_code])


if __name__ == '__main__':
    config = get_config()

    db = SqliteDatabase()

    parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter)
    parser.add_argument('-s', '--seconds', nargs='?')
    args = parser.parse_args()

    if not args.seconds:
        parser.print_help()
        sys.exit(0)

    seconds = int(args.seconds)

    chunksize = 2 ** 12  # 4096
    channels = 2  # int(config['channels']) # 1=mono, 2=stereo

    record_forever = False
    visualise_console = bool(config['mic.visualise_console'])
    visualise_plot = bool(config['mic.visualise_plot'])

    reader = MicrophoneReader(None)

    reader.start_recording(seconds=seconds,
                           chunksize=chunksize,
                           channels=channels)

    msg = ' * started recording..'
    print(colored(msg, attrs=['dark']))

    while True:
        bufferSize = int(reader.rate / reader.chunksize * seconds)

        for i in range(0, bufferSize):
            nums = reader.process_recording()

            if visualise_console:
                msg = colored('   %05d', attrs=['dark']) + colored(' %s', 'green')
                print(msg % visual_peak.calc(nums))
            else:
                msg = '   processing %d of %d..' % (i, bufferSize)
                print(colored(msg, attrs=['dark']))

        if not record_forever:
            break

    if visualise_plot:
        data = reader.get_recorded_data()[0]
        visual_plot.show(data)

    reader.stop_recording()

    msg = ' * recording has been stopped'
    print(colored(msg, attrs=['dark']))

    data = reader.get_recorded_data()

    msg = ' * recorded %d samples'
    print(colored(msg, attrs=['dark']) % len(data[0]))

    # reader.save_recorded('test.wav')

    Fs = fingerprint.DEFAULT_FS
    channel_amount = len(data)

    result = set()
    matches = []

    for channeln, channel in enumerate(data):
        # TODO: Remove prints or change them into optional logging.
        msg = '   fingerprinting channel %d/%d'
        print(colored(msg, attrs=['dark']) % (channeln + 1, channel_amount))

        matches.extend(find_matches(channel))

        msg = '   finished channel %d/%d, got %d hashes'
        print(colored(msg, attrs=['dark']) % (channeln + 1,
                                              channel_amount, len(matches)))

    total_matches_found = len(matches)
    print(matches)
    print('')

    if total_matches_found > 0:
        msg = ' ** totally found %d hash matches'
        print(colored(msg, 'green') % total_matches_found)

        song = align_matches(matches)

        msg = ' => song: %s (id=%d)\n'
        msg += '    offset: %d (%d secs)\n'
        msg += '    confidence: %d'

        print(colored(msg, 'green') % (song['SONG_NAME'], song['SONG_ID'],
                                       song['OFFSET'], song['OFFSET_SECS'],
                                       song['CONFIDENCE']))
    else:
        msg = ' ** not matches found at all'
        print(colored(msg, 'red'))

一旦我們的conf.json文件被構(gòu)建,我們將使用它并從麥克風(fēng)文件中識(shí)別音頻作為我們的主要目的。

所以完全用于音頻和圖像識(shí)別,我們將只使用四個(gè) file.pickle 包含(128 -d 矢量)圖像信息的文件,.json 文件(包含音頻指紋),識(shí)別圖像和音頻 python 文件。

3.3 創(chuàng)建用戶界面用戶界面起著重要的作用,也有更好的外觀和更好的理解。因此,為了獲得更好的界面,我們將借助 python 中的 pyqt 工具創(chuàng)建一個(gè)用戶界面,這將幫助我們識(shí)別圖像和聲音。從某種意義上說(shuō),我們可以說(shuō)這個(gè)用戶界面處理圖像和聲音識(shí)別文件。當(dāng)我們的系統(tǒng)運(yùn)行時(shí),它會(huì)調(diào)用這個(gè)用戶界面,首先詢問(wèn)用戶是否要鎖定或解鎖設(shè)備。根據(jù)用戶的選擇,執(zhí)行操作。但是如果系統(tǒng)已經(jīng)被鎖定并且如果用戶再次按下鎖定按鈕,那么它將顯示設(shè)備或系統(tǒng)已經(jīng)鎖定的提示,并且相同的情況下也適用于解鎖部分。但是如果系統(tǒng)沒(méi)有被鎖定,而用戶想要鎖定系統(tǒng),那么它會(huì)先捕獲用戶圖像并進(jìn)行驗(yàn)證。如果匹配,則通過(guò)麥克風(fēng)識(shí)別用戶聲音,然后判斷用戶是否被授權(quán)。如果模塊上的任何一個(gè)發(fā)生故障,它只會(huì)通知螺栓模塊向所有者發(fā)送警報(bào)短信,指示入侵者正在嘗試訪問(wèn)安全系統(tǒng)。

pYYBAGN6xmyAXUDLAAA1DmmxfIY605.png
圖 - 圖 8
?

上圖 8 顯示了當(dāng)安全系統(tǒng)通過(guò)螺栓設(shè)備 python 文件運(yùn)行時(shí)將調(diào)用的 UI 第一頁(yè)。系統(tǒng)會(huì)提示,詢問(wèn)用戶是否要鎖定或解鎖設(shè)備。根據(jù)用戶的選擇,將執(zhí)行操作并且 UI 將被重定向到下一頁(yè)是否會(huì)處理進(jìn)一步的處理。

poYBAGN6xnCAdssLAAA5jdqEsh8878.png
圖 - 圖 9
?

上圖 9 顯示了為處理圖像和音頻識(shí)別而創(chuàng)建的 UI。當(dāng)bolt iot調(diào)用這個(gè)python文件時(shí),它將在右側(cè)空白處顯示用戶實(shí)時(shí)圖像,在底部空白處顯示用戶實(shí)時(shí)音頻頻譜。當(dāng)這兩個(gè)驗(yàn)證正確并且如果訪問(wèn)被授予時(shí),它將向螺栓設(shè)備發(fā)送確認(rèn)以進(jìn)行進(jìn)一步處理,或者發(fā)送警報(bào)以向安全系統(tǒng)的所有者發(fā)送警報(bào)短信。

Note:- The code for UI and rest all other code along with custom built-in libraries will be provided at the end of the project section.代碼中給出的注釋可以更好地理解不同的部分。

3.4 配置文件:

現(xiàn)在,由于我們所有的模塊都準(zhǔn)備好了,我們還將準(zhǔn)備好我們的配置文件,以便通過(guò)互聯(lián)網(wǎng)調(diào)用 Bolt-IoT 設(shè)備,并在檢測(cè)到任何入侵者時(shí)發(fā)送短信。因此,為此我們需要?jiǎng)?chuàng)建一個(gè)包含以下信息的 python 文件:

SID = "Your TWILIO SSID"
AUTH_TOKEN = "Your Twilio Authentication Token"
FROM_NUMBER = "Your TWILIO Generated Number"
TO_NUMBER = "Number to which you want to send sms with +91"
API_KEY = "Your Bolt Cloud API"
Device_ID = "Your Bolt Device ID"

最后,我們所有的模塊都是單獨(dú)構(gòu)建的,現(xiàn)在我們需要將它們集成在一起使用。我們現(xiàn)在將為 BOLT_IoT 設(shè)備創(chuàng)建一個(gè)單獨(dú)的 python 文件,所有這些模塊將在其中集成并一一調(diào)用以達(dá)到預(yù)期目的。

4.集成所有模塊:

現(xiàn)在,我們將開始將所有模塊集成在一起。我們現(xiàn)在將創(chuàng)建一個(gè)主 python 文件(例如:-bolt.py),它將控制所有操作。這個(gè) python 文件將導(dǎo)入上面創(chuàng)建的配置文件,并在 python 的 OS 模塊的幫助下,它將調(diào)用第一個(gè) UI 頁(yè)面。這個(gè) UI 頁(yè)面將通過(guò)一個(gè)一個(gè)調(diào)用面部和音頻模塊來(lái)處理進(jìn)一步的處理并識(shí)別這個(gè)人。如果識(shí)別成功完成,則 UI 頁(yè)面將控制權(quán)傳回主 python 文件 (bolt.py),指示識(shí)別成功并要求螺栓模塊成功鎖定或解鎖系統(tǒng)。這可以通過(guò)打開或關(guān)閉 Led 來(lái)顯示,即當(dāng)從 UI 頁(yè)面接收到肯定控制時(shí),我們將根據(jù)用戶從第一個(gè) UI 頁(yè)面中選擇的選擇向螺栓模塊發(fā)送信號(hào),使特定引腳為高電平或低電平,即是鎖定還是解鎖,并在那里放置一個(gè)發(fā)光或關(guān)閉的 LED。人們可以更換這個(gè) LED,也可以將伺服電機(jī)放在那個(gè)螺栓 IoT 引腳或任何其他東西以顯示代碼的物理工作,因?yàn)槔锩娴囊磺卸急3植蛔儭?/font>

假設(shè),如果模塊無(wú)法識(shí)別該人,即如果識(shí)別失敗,則 UI 頁(yè)面會(huì)將負(fù)面控制發(fā)送回主 python 文件(bolt.py)。一旦主 python 文件從 UI 頁(yè)面接收到負(fù)面控制,它將請(qǐng)求 Twilio 向用戶發(fā)送一條警報(bào)短信,提醒他們有入侵者,最后蜂鳴器會(huì)發(fā)出聲音通知附近的人。

import os
import conf,json,time
from boltiot import Sms, Bolt
mybolt = Bolt(conf.API_Key, conf.Device_ID)
sms = Sms(conf.SID,conf.AUTH_Token,conf.TO_Number,conf.FROM_Number)
os.system('python 1st_page.py')
f = open("del.txt", "r")
res = []
for x in f:
	res.append(x)
f.close()
if int(res[0])==0:
	print("Unlocking device")
	mybolt.digitalWrite('0','HIGH')
	os.remove("del.txt")
elif int(res[0])==1:
	print("Locking device")
	mybolt.digitalWrite('0','LOW')
	os.remove("del.txt")
elif int(res[0])==2:
	print("Making request to Twilio to send an sms")
	response = sms.send_sms("Intruder detected, Someone trying to access security system")
	print("Response received from twilio = " + str(response))
	print("Status of sms = " +str(response.status))
	os.remove("del.txt")

上面的代碼演示了主代碼文件 (bolt.py),它充當(dāng)驅(qū)動(dòng)程序類并完成上述必要的工作。

簡(jiǎn)單的電路圖

pYYBAGN6xnSAV1b5AADabX1_c8k836.png
圖 - 10
?

上圖 - 10 顯示了電路圖。由于我們所有的工作都依賴于代碼,因此電路設(shè)置很小。再次提及,人們還可以設(shè)置任何設(shè)備或任何其他東西來(lái)代替 led,當(dāng)安全系統(tǒng)為特定用戶授予訪問(wèn)權(quán)限時(shí),它們將起作用。

注意:-我們的bolt模塊必須聯(lián)網(wǎng),我們只需要運(yùn)行我們的驅(qū)動(dòng)python文件即可執(zhí)行,即bolt.py和rest文件將在內(nèi)部一一調(diào)用。所有文件也應(yīng)該在同一目錄中。

5. 示范

正如上面已經(jīng)從理論上解釋了代碼是如何工作的,現(xiàn)在讓我們看看它是否實(shí)際發(fā)生。下面的結(jié)果截圖展示了實(shí)現(xiàn)所有模塊的項(xiàng)目的完整工作,并顯示了項(xiàng)目是否按上述方式工作。現(xiàn)在為了更好地理解,讓我們也將我們的演示分成不同的部分。

We have also talked about the buzzer which will make sound during intruder detection. Bu due to some problem my buzzer destroyed so I have not added it in the circuit. One can add it to the circuit with a small changes in the bolt.py file.
  • 第 1 部分 - 如果授予訪問(wèn)權(quán)限,則演示鎖定或解鎖系統(tǒng)
?
?
?
poYBAGN6xnaAOqMTAABCm-YY9YU980.png
?
1 / 4 ?啟動(dòng)項(xiàng)目時(shí)打開的第一頁(yè)允許您選擇鎖定或解鎖與該系統(tǒng)連接的任何設(shè)備。
?
Note :- We can place anything instead of LED. Suppose we connect the door control with the BOLT IOT then when the system identifies the user it performs locking or unlocking of door based on his choice selected on the first page.
Due to lack of equipment's I just used an LED to demonstrate the working.
  • 第 2 部分 - 演示當(dāng)任何模塊無(wú)法識(shí)別人員時(shí)會(huì)發(fā)生什么
?
?
?
pYYBAGN6xniAX-QeAAB1ZGUajtY164.png
?
1 / 2 ?第二種情況顯示當(dāng)任何模塊無(wú)法識(shí)別用戶時(shí)會(huì)發(fā)生什么。
?
  • 第 3 部分 - 演示當(dāng)用戶嘗試鎖定已鎖定的系統(tǒng)或解鎖已打開的系統(tǒng)時(shí)會(huì)發(fā)生什么。
poYBAGN6xnqANL0MAABIOh-8DHo492.png
有人試圖鎖定并且已經(jīng)鎖定系統(tǒng)的情況。
?

Note:- All the codes are provided while explanation. Remaining two GUI codes will be provided at the end of the sections.

5. 結(jié)論

該項(xiàng)目演示了使用圖像和聲音處理的安全系統(tǒng)人們還可以將生物識(shí)別傳感器添加到給定的項(xiàng)目中,以使其更加安全。為了保持項(xiàng)目簡(jiǎn)短,我刪除了生物識(shí)別部分。一旦我們添加了生物識(shí)別傳感器,我們就可以實(shí)現(xiàn)更高的安全性,包括圖像、聲音和指紋,入侵者將很難繞過(guò)系統(tǒng)。


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評(píng)論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數(shù)據(jù)手冊(cè)
  2. 1.06 MB  |  532次下載  |  免費(fèi)
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費(fèi)
  5. 3TC358743XBG評(píng)估板參考手冊(cè)
  6. 1.36 MB  |  330次下載  |  免費(fèi)
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費(fèi)
  9. 5元宇宙深度解析—未來(lái)的未來(lái)-風(fēng)口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費(fèi)
  11. 6迪文DGUS開發(fā)指南
  12. 31.67 MB  |  194次下載  |  免費(fèi)
  13. 7元宇宙底層硬件系列報(bào)告
  14. 13.42 MB  |  182次下載  |  免費(fèi)
  15. 8FP5207XR-G1中文應(yīng)用手冊(cè)
  16. 1.09 MB  |  178次下載  |  免費(fèi)

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費(fèi)
  3. 2555集成電路應(yīng)用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費(fèi)
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費(fèi)
  7. 4開關(guān)電源設(shè)計(jì)實(shí)例指南
  8. 未知  |  21549次下載  |  免費(fèi)
  9. 5電氣工程師手冊(cè)免費(fèi)下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費(fèi)
  11. 6數(shù)字電路基礎(chǔ)pdf(下載)
  12. 未知  |  13750次下載  |  免費(fèi)
  13. 7電子制作實(shí)例集錦 下載
  14. 未知  |  8113次下載  |  免費(fèi)
  15. 8《LED驅(qū)動(dòng)電路設(shè)計(jì)》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費(fèi)
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537798次下載  |  免費(fèi)
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費(fèi)
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費(fèi)
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費(fèi)
  11. 6電路仿真軟件multisim 10.0免費(fèi)下載
  12. 340992  |  191187次下載  |  免費(fèi)
  13. 7十天學(xué)會(huì)AVR單片機(jī)與C語(yǔ)言視頻教程 下載
  14. 158M  |  183279次下載  |  免費(fèi)
  15. 8proe5.0野火版下載(中文版免費(fèi)下載)
  16. 未知  |  138040次下載  |  免費(fèi)