ubantu / linux mint安装howdy人脸识别

1、首先要自备好梯子

期间需要安装一些东西,镜像在国外,下载得很慢,甚至安装失败

2、终端命令

sudo add-apt-repository ppa:boltgolt/howdy
sudo apt update
sudo apt install howdy

安装时会出现f/b/s三个选项,fast/balance/security分别表示识别快、平衡、安全,根据需要选择

3、配置文件

#安装v4l-utils,用于检测摄像头设备
sudo apt-get install v4l-utils
#查看摄像头设备,一般/dev/video0就是摄像头设备
v4l2-ctl --list-devices
#修改howdy的配置文件
sudo vim /lib/security/howdy/config.ini
#将device_path修改为/dev/video0
device_path = /dev/video0

4、添加人脸

sudo howdy add
# 输入一个24字符以内的标签用于区分,然后会自动打开摄像头进行人脸扫描,完成之后提示Scan complete

5、设置登录解锁

完成第四步就已经可以人脸使用sudo了,但锁屏还不能使用

5.1 终端命令提升howdy权限

sudo chmod 777 -R /lib/security/howdy
若不能解决

5.2 终端命令行

cd /lib/security/howdy
sudo vim compare.py

compare.py内容替换为

# Compare incomming video with known faces
# Running in a local python instance to get around PATH issues# Import time so we can start timing asap
import time# Start timing
timings = {"st": time.time()
}# Import required modules
import sys
# Some user libraries will make howdy dosn't work
sys.path.append("/lib/security/howdy/")
for path in range(len(sys.path)): if len(sys.path[path])>5 and sys.path[path][:5]=="/home":sys.path[path]=""
import os
import json
import configparser
import dlib
import cv2
import datetime
import atexit
import subprocess
import snapshot
import numpy as np
import _thread as threadfrom i18n import _
from recorders.video_capture import VideoCapturedef exit(code=None):"""Exit while closeing howdy-gtk properly"""global gtk_proc# Exit the auth ui process if there is oneif "gtk_proc" in globals():gtk_proc.terminate()# Exit compareif code is not None:sys.exit(code)def init_detector(lock):"""Start face detector, encoder and predictor in a new thread"""global face_detector, pose_predictor, face_encoder# Test if at lest 1 of the data files is there and abort if it's notif not os.path.isfile(PATH + "/dlib-data/shape_predictor_5_face_landmarks.dat"):print(_("Data files have not been downloaded, please run the following commands:"))print("\n\tcd " + PATH + "/dlib-data")print("\tsudo ./install.sh\n")lock.release()exit(1)# Use the CNN detector if enabledif use_cnn:face_detector = dlib.cnn_face_detection_model_v1(PATH + "/dlib-data/mmod_human_face_detector.dat")else:face_detector = dlib.get_frontal_face_detector()# Start the others regardlesspose_predictor = dlib.shape_predictor(PATH + "/dlib-data/shape_predictor_5_face_landmarks.dat")face_encoder = dlib.face_recognition_model_v1(PATH + "/dlib-data/dlib_face_recognition_resnet_model_v1.dat")# Note the time it took to initialize detectorstimings["ll"] = time.time() - timings["ll"]lock.release()def make_snapshot(type):"""Generate snapshot after detection"""snapshot.generate(snapframes, [type + _(" LOGIN"),_("Date: ") + datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S UTC"),_("Scan time: ") + str(round(time.time() - timings["fr"], 2)) + "s",_("Frames: ") + str(frames) + " (" + str(round(frames / (time.time() - timings["fr"]), 2)) + "FPS)",_("Hostname: ") + os.uname().nodename,_("Best certainty value: ") + str(round(lowest_certainty * 10, 1))])def send_to_ui(type, message):"""Send message to the auth ui"""global gtk_proc# Only execute of the proccess startedif "gtk_proc" in globals():# Format message so the ui can parse itmessage = type + "=" + message + " \n"# Try to send the message to the auth ui, but it's okay if that failstry:gtk_proc.stdin.write(bytearray(message.encode("utf-8")))gtk_proc.stdin.flush()except IOError:pass# Make sure we were given an username to tast against
if len(sys.argv) < 2:exit(12)# Get the absolute path to the current directory
PATH = os.path.abspath(__file__ + "/..")# The username of the user being authenticated
user = sys.argv[1]
# The model file contents
models = []
# Encoded face models
encodings = []
# Amount of ignored 100% black frames
black_tries = 0
# Amount of ingnored dark frames
dark_tries = 0
# Total amount of frames captured
frames = 0
# Captured frames for snapshot capture
snapframes = []
# Tracks the lowest certainty value in the loop
lowest_certainty = 10
# Face recognition/detection instances
face_detector = None
pose_predictor = None
face_encoder = None# Try to load the face model from the models folder
try:models = json.load(open(PATH + "/models/" + user + ".dat"))for model in models:encodings += model["data"]
except FileNotFoundError:exit(10)# Check if the file contains a model
if len(models) < 1:exit(10)# Read config from disk
config = configparser.ConfigParser()
config.read(PATH + "/config.ini")# Get all config values needed
use_cnn = config.getboolean("core", "use_cnn", fallback=False)
timeout = config.getint("video", "timeout", fallback=5)
dark_threshold = config.getfloat("video", "dark_threshold", fallback=50.0)
video_certainty = config.getfloat("video", "certainty", fallback=3.5) / 10
end_report = config.getboolean("debug", "end_report", fallback=False)
capture_failed = config.getboolean("snapshots", "capture_failed", fallback=False)
capture_successful = config.getboolean("snapshots", "capture_successful", fallback=False)
gtk_stdout = config.getboolean("debug", "gtk_stdout", fallback=False)# Send the gtk outupt to the terminal if enabled in the config
gtk_pipe = sys.stdout if gtk_stdout else subprocess.DEVNULL# Start the auth ui, register it to be always be closed on exit
try:gtk_proc = subprocess.Popen(["../howdy-gtk/src/init.py", "--start-auth-ui"], stdin=subprocess.PIPE, stdout=gtk_pipe, stderr=gtk_pipe)atexit.register(exit)
except FileNotFoundError:pass# Write to the stdin to redraw ui
send_to_ui("M", _("Starting up..."))# Save the time needed to start the script
timings["in"] = time.time() - timings["st"]# Import face recognition, takes some time
timings["ll"] = time.time()# Start threading and wait for init to finish
lock = thread.allocate_lock()
lock.acquire()
thread.start_new_thread(init_detector, (lock, ))# Start video capture on the IR camera
timings["ic"] = time.time()video_capture = VideoCapture(config)# Read exposure from config to use in the main loop
exposure = config.getint("video", "exposure", fallback=-1)# Note the time it took to open the camera
timings["ic"] = time.time() - timings["ic"]# wait for thread to finish
lock.acquire()
lock.release()
del lock# Fetch the max frame height
max_height = config.getfloat("video", "max_height", fallback=0.0)
# Get the height of the image
height = video_capture.internal.get(cv2.CAP_PROP_FRAME_HEIGHT) or 1# Calculate the amount the image has to shrink
scaling_factor = (max_height / height) or 1# Fetch config settings out of the loop
timeout = config.getint("video", "timeout")
dark_threshold = config.getfloat("video", "dark_threshold")
end_report = config.getboolean("debug", "end_report")# Initiate histogram equalization
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))# Let the ui know that we're ready
send_to_ui("M", _("Identifying you..."))# Start the read loop
frames = 0
valid_frames = 0
timings["fr"] = time.time()
dark_running_total = 0while True:# Increment the frame count every loopframes += 1# Form a string to let the user know we're real busyui_subtext = "Scanned " + str(valid_frames - dark_tries) + " frames"if (dark_tries > 1):ui_subtext += " (skipped " + str(dark_tries) + " dark frames)"# Show it in the ui as subtextsend_to_ui("S", ui_subtext)# Stop if we've exceded the time limitif time.time() - timings["fr"] > timeout:# Create a timeout snapshot if enabledif capture_failed:make_snapshot(_("FAILED"))if dark_tries == valid_frames:print(_("All frames were too dark, please check dark_threshold in config"))print(_("Average darkness: {avg}, Threshold: {threshold}").format(avg=str(dark_running_total / max(1, valid_frames)), threshold=str(dark_threshold)))exit(13)else:exit(11)# Grab a single frame of videoframe, gsframe = video_capture.read_frame()gsframe = clahe.apply(gsframe)# If snapshots have been turned onif capture_failed or capture_successful:# Start capturing frames for the snapshotif len(snapframes) < 3:snapframes.append(frame)# Create a histogram of the image with 8 valueshist = cv2.calcHist([gsframe], [0], None, [8], [0, 256])# All values combined for percentage calculationhist_total = np.sum(hist)# Calculate frame darknessdarkness = (hist[0] / hist_total * 100)# If the image is fully black due to a bad camera read,# skip to the next frameif (hist_total == 0) or (darkness == 100):black_tries += 1continuedark_running_total += darknessvalid_frames += 1# If the image exceeds darkness threshold due to subject distance,# skip to the next frameif (darkness > dark_threshold):dark_tries += 1continue# If the hight is too highif scaling_factor != 1:# Apply that factor to the frameframe = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)gsframe = cv2.resize(gsframe, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA)# Get all faces from that frame as encodings# Upsamples 1 timeface_locations = face_detector(gsframe, 1)# Loop through each facefor fl in face_locations:if use_cnn:fl = fl.rect# Fetch the faces in the imageface_landmark = pose_predictor(frame, fl)face_encoding = np.array(face_encoder.compute_face_descriptor(frame, face_landmark, 1))# Match this found face against a known facematches = np.linalg.norm(encodings - face_encoding, axis=1)# Get best matchmatch_index = np.argmin(matches)match = matches[match_index]# Update certainty if we have a new lowif lowest_certainty > match:lowest_certainty = match# Check if a match that's confident enoughif 0 < match < video_certainty:timings["tt"] = time.time() - timings["st"]timings["fl"] = time.time() - timings["fr"]# If set to true in the config, print debug textif end_report:def print_timing(label, k):"""Helper function to print a timing from the list"""print("  %s: %dms" % (label, round(timings[k] * 1000)))# Print a nice timing reportprint(_("Time spent"))print_timing(_("Starting up"), "in")print(_("  Open cam + load libs: %dms") % (round(max(timings["ll"], timings["ic"]) * 1000, )))print_timing(_("  Opening the camera"), "ic")print_timing(_("  Importing recognition libs"), "ll")print_timing(_("Searching for known face"), "fl")print_timing(_("Total time"), "tt")print(_("\nResolution"))width = video_capture.fw or 1print(_("  Native: %dx%d") % (height, width))# Save the new size for diagnosticsscale_height, scale_width = frame.shape[:2]print(_("  Used: %dx%d") % (scale_height, scale_width))# Show the total number of frames and calculate the FPS by deviding it by the total scan timeprint(_("\nFrames searched: %d (%.2f fps)") % (frames, frames / timings["fl"]))print(_("Black frames ignored: %d ") % (black_tries, ))print(_("Dark frames ignored: %d ") % (dark_tries, ))print(_("Certainty of winning frame: %.3f") % (match * 10, ))print(_("Winning model: %d (\"%s\")") % (match_index, models[match_index]["label"]))# Make snapshot if enabledif capture_successful:make_snapshot(_("SUCCESSFUL"))# Run rubberstamps if enabledif config.getboolean("rubberstamps", "enabled", fallback=False):import rubberstampssend_to_ui("S", "")if "gtk_proc" not in vars():gtk_proc = Nonerubberstamps.execute(config, gtk_proc, {"video_capture": video_capture,"face_detector": face_detector,"pose_predictor": pose_predictor,"clahe": clahe})# End peacefullyexit(0)if exposure != -1:# For a strange reason on some cameras (e.g. Lenoxo X1E) setting manual exposure works only after a couple frames# are captured and even after a delay it does not always work. Setting exposure at every frame is reliable though.video_capture.internal.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0)  # 1 = Manualvideo_capture.internal.set(cv2.CAP_PROP_EXPOSURE, float(exposure))

并新建i18n.py

# Support file for translations# Import modules
import gettext
import os# Get the right translation based on locale, falling back to base if none found
translation = gettext.translation("core", localedir=os.path.join(os.path.dirname(__file__), 'locales'), fallback=True)
translation.install()# Export translation function as _
_ = translation.gettext

6、启动howdy

sudo howdy disable 1
sudo howdy disable 0

howdy常用命令:

sudo howdy list:面部模型记录
sudo howdy remove face_ID:删除指定ID的面部记录
sudo howdy clear:清除所有面部模型记录
sudo howdy disable 1:禁用howdy功能
sudo howdy disable 0:启用howdy功能

linux ubantu / linux mint安装howdy人脸识别相关推荐

  1. 工厂企业安装使用人脸识别考勤系统的好处

    工厂企业安装使用人脸识别考勤系统的好处 大型工厂企业员工数量庞大,上下班时间人员流动极大,在日常的人员管理中,单靠保安以人工登记放行的方式根本无法应对人员安防管理方面的工作,传统的考勤卡系统又容易发生 ...

  2. linux桌面版mint安装,在Linux Mint系统上安装Spotify桌面客户端的方法

    本文介绍在Linux Mint系统上安装Spotify桌面客户端的方法. 简介 Spotify是世界上最大的音乐流媒体服务,每天都有成千上万人使用它来听音乐和消费播客,包括许多Linux用户,您可以通 ...

  3. OpenSSL编译说明:Linux结合libcurl库编程实现人脸识别和车牌识别

    目录 一   写在前面 二   编译OpenSSL支持libcurl的https访问 ① 下载openssl库 ② 把库的开源配置包安装在指定文件夹并编译 三   编写人脸识别代码第一次 ① 翔云人工 ...

  4. python 3.6.6安装fake_人脸识别替换之fakeApp,deepfacelib

    人脸识别替换之fakeApp,deepfacelib 19-09-11 14:52:07 丁宇聪 3558 这两天陌陌的zao软件很火,勾起了我研究人脸识别的热情.一开始使用的是fakeApp这款软件 ...

  5. 【python】MAC安装openCV人脸识别

    一.OpenCV 1. 安装openCV pip install opencv-python 但因为openCV是外网的库,安装可能回很慢,建议从[清华镜像园]进行安装 pip3 install -i ...

  6. python dlib人脸识别_python3+dlib人脸识别及情绪分析

    一.介绍 我想做的是基于人脸识别的表情(情绪)分析.看到网上也是有很多的开源库提供使用,为开发提供了很大的方便.我选择目前用的比较多的dlib库进行人脸识别与特征标定.使用python也缩短了开发周期 ...

  7. linux添加人脸识别认证

    简介 howdy 人脸识别,可以实现Linux认证.只要有摄像头都可以使用. 安装 在Archlinux和Manjaro上可以直接使用yay进行安装 yay -S howdy Ubuntu系列可以添加 ...

  8. linux的系统监视器图片_用Nvidia Jetson Nano 2GB和Python构建一个价值60美元的人脸识别系统...

    作者|Adam Geitgey 编译|Flin 来源|medium 新的Nvidia Jetson Nano 2GB开发板(今天宣布!)是一款单板机,售价59美元,运行带有GPU加速的人工智能软件. ...

  9. linux的系统监视器图片_用Nvidia Jetson Nano 2GB和Python构建一个价值60美元的人脸识别系统 - 人工智能遇见磐创...

    作者|Adam Geitgey 编译|Flin 来源|medium 新的Nvidia Jetson Nano 2GB开发板(今天宣布!)是一款单板机,售价59美元,运行带有GPU加速的人工智能软件. ...

最新文章

  1. 测序发展史,150年的风雨历程 (第二版)
  2. 我喜爱的FireFox插件
  3. java javaw javaws MC_java和 javaw 以及 javaws的區別
  4. scikit-learn Adaboost类库使用小结
  5. 【Groovy】Groovy 脚本调用 ( Java 类中调用 Groovy 脚本 )
  6. html表单 传递 符号,HTML源码中 form 标签的 enctype 属性
  7. mysql根据已有表创建新表_SQL根据现有表新建一张表
  8. Project Server 2010 好难装阿!
  9. 的房费重构——上,下位机的复议
  10. 如何时刻保持在目标的正确轨道上
  11. 史上最简单,利用Spring-boot快速搭建邮件发送服务!
  12. laravel实现mysql读写分离
  13. VOIP技术的专业性网站
  14. 新东方报名系统服务器地址,新东方邮箱服务器地址
  15. 李佳明的成长经历与留学选择
  16. win10系统获取管理员权限的设置方法一览
  17. SQL server数据库安装包下载
  18. python爬取携程网游记_Python爬虫案例:爬取携程评论
  19. ps aux|grep xxx详解
  20. 【财富空间】中国AI应用最新白皮书:金融、汽车、医疗和零售将受AI影响最大,或为参与者带来19000亿增益价值

热门文章

  1. 合并Firefox的书签
  2. 原生开发引入高德地图
  3. python什么工作好找女朋友_什么工作最好找女朋友?
  4. Windows下使用Yolov3(GPU)训练+测试自己的数据集
  5. 晚上睡不着觉该怎么办?
  6. 小白入门编程heiio world,来一名计算机自考生
  7. 新技术下的智慧政府门户网站群建设升级发展之路
  8. 用vb编写websocket客户端示例(每秒百万弹幕吞吐量)
  9. 馈线接头制作步骤及说明
  10. Android开发教程--设置ImageView图片的显示比例