Merge pull request #166 from accek/manual-exposure
Manual exposure support for OpenCV
This commit is contained in:
commit
37bb8f3511
6 changed files with 182 additions and 10 deletions
43
README.md
43
README.md
|
|
@ -1,16 +1,31 @@
|
|||
# Howdy for Linux [](https://travis-ci.org/boltgolt/howdy) [](https://github.com/boltgolt/howdy/releases)
|
||||

|
||||
|
||||
Windows Hello™ style authentication for Linux. Use your built-in IR emitters and camera in combination with face recognition to prove who you are.
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/boltgolt/howdy">
|
||||
<img src="https://img.shields.io/travis/boltgolt/howdy/master.svg">
|
||||
</a>
|
||||
<a href="https://github.com/boltgolt/howdy/releases">
|
||||
<img src="https://img.shields.io/github/release/boltgolt/howdy.svg?colorB=4c1">
|
||||
</a>
|
||||
<a href="https://github.com/boltgolt/howdy/graphs/contributors">
|
||||
<img src="https://img.shields.io/github/contributors/boltgolt/howdy.svg?style=flat">
|
||||
</a>
|
||||
<a href="https://www.buymeacoffee.com/boltgolt">
|
||||
<img src="https://img.shields.io/badge/endpoint.svg?url=https://boltgolt.nl/howdy/shield.json">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Howdy provides Windows Hello™ style authentication for Linux. Use your built-in IR emitters and camera in combination with facial recognition to prove who you are.
|
||||
|
||||
Using the central authentication system (PAM), this works everywhere you would otherwise need your password: Login, lock screen, sudo, su, etc.
|
||||
|
||||
## Installation
|
||||
|
||||
Howdy is currently available for Debian/Ubuntu and Arch Linux. If you’re interested in packaging Howdy for your distro, don’t hesitate to open an issue. If you're using Fedora and want to work on a RPM port, take a look at [#26](https://github.com/boltgolt/howdy/issues/26).
|
||||
Howdy is currently available for Debian/Ubuntu, Arch Linux and Fedora. If you’re interested in packaging Howdy for your distro, don’t hesitate to open an issue.
|
||||
|
||||
**Note:** The build of dlib can hang on 100% for over a minute, give it time.
|
||||
|
||||
### Debian (Ubuntu, Linux Mint, etc)
|
||||
### Ubuntu or Linux Mint
|
||||
|
||||
Run the installer by pasting (`ctrl+shift+V`) the following commands into the terminal one at a time:
|
||||
|
||||
|
|
@ -22,6 +37,10 @@ sudo apt install howdy
|
|||
|
||||
This will guide you through the installation.
|
||||
|
||||
### Debian
|
||||
|
||||
Download the .deb file from the [Releases page](https://github.com/boltgolt/howdy/releases) and install with gdebi.
|
||||
|
||||
### Arch Linux
|
||||
|
||||
Install the `howdy` package from the AUR. For AUR installation instructions, take a look at this [wiki page](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages).
|
||||
|
|
@ -29,7 +48,9 @@ Install the `howdy` package from the AUR. For AUR installation instructions, tak
|
|||
You will need to do some additional configuration steps. Please read the [ArchWiki entry](https://wiki.archlinux.org/index.php/Howdy) for more information.
|
||||
|
||||
### Fedora
|
||||
The `howdy` package is now available in a [Fedora COPR repository](https://copr.fedorainfracloud.org/coprs/luya/howdy/) by simply execute the following command from a terminal:
|
||||
_Maintainer: [@luyatshimbalanga](https://github.com/luyatshimbalanga)_
|
||||
|
||||
The `howdy` package is available as a [Fedora COPR repository](https://copr.fedorainfracloud.org/coprs/luya/howdy/), install it by simply executing the following commands in a terminal:
|
||||
|
||||
```
|
||||
sudo dnf copr enable luya/howdy
|
||||
|
|
@ -38,11 +59,11 @@ sudo dnf install howdy
|
|||
|
||||
## Setup
|
||||
|
||||
After installation, you need to let Howdy learn your face. Run `sudo howdy add` to add a face model.
|
||||
After installation, Howdy needs needs to learn what you look like so it can recognise you later. Run `sudo howdy add` to add a face model.
|
||||
|
||||
If nothing went wrong we should be able to run sudo by just showing your face. Open a new terminal and run `sudo -i` to see it in action.
|
||||
|
||||
If you're curious you can run `sudo howdy config` to open the central config file and see the options Howdy has. On most systems this will open the nano editor, where you have to press `ctrl`+`x` to save your changes.
|
||||
If you're curious you can run `sudo howdy config` to open the central config file and see the options Howdy has to offer. On most systems this will open the nano editor, where you have to press `ctrl`+`x` to save your changes.
|
||||
|
||||
## CLI
|
||||
|
||||
|
|
@ -57,7 +78,7 @@ howdy [-U user] [-y] command [argument]
|
|||
|-----------|-----------------------------------------------|
|
||||
| `add` | Add a new face model for an user |
|
||||
| `clear` | Remove all face models for an user |
|
||||
| `config` | Open the config file in gedit |
|
||||
| `config` | Open the config file in your default editor |
|
||||
| `disable` | Disable or enable howdy |
|
||||
| `list` | List all saved face models for an user |
|
||||
| `remove` | Remove a specific model for an user |
|
||||
|
|
@ -67,7 +88,7 @@ howdy [-U user] [-y] command [argument]
|
|||
|
||||
The easiest ways to contribute to Howdy is by starring the repository and opening GitHub issues for features you'd like to see. If you want to do more, you can also [buy me a coffee](https://www.buymeacoffee.com/boltgolt).
|
||||
|
||||
Code contributions are also very welcome. If you want to port Howdy to another distro, feel free to contact me.
|
||||
Code contributions are also very welcome. If you want to port Howdy to another distro, feel free to open an issue for that too.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
|
@ -77,8 +98,10 @@ If you encounter an error that hasn't been reported yet, don't be afraid to open
|
|||
|
||||
## A note on security
|
||||
|
||||
This script is in no way as secure as a password and will never be. Although it's harder to fool than normal face recognition, a person who looks similar to you or well-printed photo of you could be enough to do it.
|
||||
This package is in no way as secure as a password and will never be. Although it's harder to fool than normal face recognition, a person who looks similar to you or well-printed photo of you could be enough to do it. Howdy is a more quick and convenient way of logging in, not a more secure one.
|
||||
|
||||
To minimize the chance of this program being compromised, it's recommended to leave Howdy in `/lib/security` and to keep it read-only.
|
||||
|
||||
DO NOT USE HOWDY AS THE SOLE AUTHENTICATION METHOD FOR YOUR SYSTEM.
|
||||
|
||||
|
||||
|
|
|
|||
32
archlinux/.SRCINFO
Normal file
32
archlinux/.SRCINFO
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
pkgbase = howdy
|
||||
pkgdesc = Windows Hello for Linux
|
||||
pkgver = 2.5.0
|
||||
pkgrel = 1
|
||||
url = https://github.com/boltgolt/howdy
|
||||
arch = x86_64
|
||||
license = MIT
|
||||
makedepends = python2-sphinx
|
||||
makedepends = git
|
||||
makedepends = cmake
|
||||
makedepends = pkgfile
|
||||
makedepends = python-pip
|
||||
depends = opencv
|
||||
depends = hdf5
|
||||
depends = python2
|
||||
depends = python3
|
||||
depends = python-pillow
|
||||
depends = python-face_recognition_models
|
||||
depends = python-click
|
||||
depends = python-numpy
|
||||
backup = usr/lib/security/howdy/config.ini
|
||||
source = https://github.com/boltgolt/howdy/archive/v2.5.0.tar.gz
|
||||
source = https://downloads.sourceforge.net/project/pam-python/pam-python-1.0.6-1/pam-python-1.0.6.tar.gz
|
||||
source = https://sourceforge.net/p/pam-python/tickets/_discuss/thread/5dc8cfd5/5839/attachment/pam-python-1.0.6-fedora.patch
|
||||
source = https://sourceforge.net/p/pam-python/tickets/_discuss/thread/5dc8cfd5/5839/attachment/pam-python-1.0.6-gcc8.patch
|
||||
sha256sums = a42c278f05866a6a616e8f5dd8349e35769063a229c236e680e566c5a6580334
|
||||
sha256sums = 0ef4dda35da14088afb1640266415730a6e0274bea934917beb5aca90318f853
|
||||
sha256sums = acb9d1b5cf7cad73d5524334b7954431bb9b90f960980378c538907e468c34b5
|
||||
sha256sums = 02dd9a4d8ec921ff9a2408183f290f08102e3f9e0151786ae7220a4d550bfe24
|
||||
|
||||
pkgname = howdy
|
||||
|
||||
88
archlinux/PKGBUILD
Normal file
88
archlinux/PKGBUILD
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
# Maintainer: boltgolt <boltgolt@gmail.com>
|
||||
# Maintainer: Kelley McChesney <kelley@kelleymcchesney.us>
|
||||
pkgname=howdy
|
||||
pkgver=2.5.0
|
||||
pkgrel=1
|
||||
pkgdesc="Windows Hello for Linux"
|
||||
arch=('x86_64')
|
||||
url="https://github.com/boltgolt/howdy"
|
||||
license=('MIT')
|
||||
depends=(
|
||||
'opencv'
|
||||
'hdf5'
|
||||
'python2'
|
||||
'python3'
|
||||
'python-pillow'
|
||||
'python-face_recognition_models'
|
||||
'python-click'
|
||||
'python-numpy'
|
||||
)
|
||||
makedepends=(
|
||||
'python2-sphinx'
|
||||
'git'
|
||||
'cmake'
|
||||
'pkgfile'
|
||||
'python-pip'
|
||||
)
|
||||
backup=('usr/lib/security/howdy/config.ini')
|
||||
source=("https://github.com/boltgolt/howdy/archive/v2.5.0.tar.gz"
|
||||
"https://downloads.sourceforge.net/project/pam-python/pam-python-1.0.6-1/pam-python-1.0.6.tar.gz"
|
||||
"https://sourceforge.net/p/pam-python/tickets/_discuss/thread/5dc8cfd5/5839/attachment/pam-python-1.0.6-fedora.patch"
|
||||
"https://sourceforge.net/p/pam-python/tickets/_discuss/thread/5dc8cfd5/5839/attachment/pam-python-1.0.6-gcc8.patch")
|
||||
sha256sums=('a42c278f05866a6a616e8f5dd8349e35769063a229c236e680e566c5a6580334'
|
||||
'0ef4dda35da14088afb1640266415730a6e0274bea934917beb5aca90318f853'
|
||||
'acb9d1b5cf7cad73d5524334b7954431bb9b90f960980378c538907e468c34b5'
|
||||
'02dd9a4d8ec921ff9a2408183f290f08102e3f9e0151786ae7220a4d550bfe24')
|
||||
prepare() {
|
||||
# Preparing dlib with GPU here
|
||||
git clone --depth 1 https://github.com/davisking/dlib.git dlib_clone
|
||||
|
||||
# Preparing pam-python to be installed
|
||||
cd pam-python-1.0.6
|
||||
sed -i'' 's|#!/usr/bin/python -W default|#!/usr/bin/python2 -W default|g' src/setup.py
|
||||
sed -i'' 's|#!/usr/bin/python -W default|#!/usr/bin/python2 -W default|g' src/test.py
|
||||
sed -i'' 's|LIBDIR ?= /lib/security|LIBDIR ?= /usr/lib/security|g' src/Makefile
|
||||
sed -i'' 's|sphinx-build|sphinx-build2|g' doc/Makefile
|
||||
patch -p1 < ../pam-python-1.0.6-fedora.patch
|
||||
patch -p1 < ../pam-python-1.0.6-gcc8.patch
|
||||
|
||||
# Doing some fixes for pam-python so that it can compile
|
||||
sudo pkgfile -u
|
||||
sudo pkgfile /usr/include/sys/cdefs.h core/glibc
|
||||
cd ..
|
||||
}
|
||||
build() {
|
||||
# Building pam-python
|
||||
cd pam-python-1.0.6
|
||||
PREFIX=/usr make
|
||||
cd ..
|
||||
|
||||
# Building dlib with GPU
|
||||
cd dlib_clone
|
||||
python setup.py build
|
||||
}
|
||||
package() {
|
||||
PIP_CONFIG_FILE=/dev/null pip install --isolated --root="$pkgdir" --ignore-installed --no-deps face_recognition
|
||||
|
||||
# Installing dlib with GPU
|
||||
cd dlib_clone
|
||||
python3 setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA --root="$pkgdir/" --optimize=1 --skip-build
|
||||
cd ..
|
||||
|
||||
# Installing pam-python
|
||||
cd pam-python-1.0.6
|
||||
PREFIX=/usr make DESTDIR="$pkgdir/" install
|
||||
cd ..
|
||||
|
||||
# Installing the proper license files and the rest of howdy
|
||||
cd howdy-$pkgver
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
mkdir -p "$pkgdir/usr/lib/security/howdy"
|
||||
cp -r src/* "$pkgdir/usr/lib/security/howdy"
|
||||
chmod 600 -R "$pkgdir/usr/lib/security/howdy"
|
||||
mkdir -p "$pkgdir/usr/bin"
|
||||
ln -s /lib/security/howdy/cli.py "$pkgdir/usr/bin/howdy"
|
||||
chmod +x "$pkgdir/usr/lib/security/howdy/cli.py"
|
||||
mkdir -p "$pkgdir/usr/share/bash-completion/completions"
|
||||
cp autocomplete/howdy "$pkgdir/usr/share/bash-completion/completions/howdy"
|
||||
}
|
||||
|
|
@ -37,6 +37,9 @@ if fw != -1:
|
|||
if fh != -1:
|
||||
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, fh)
|
||||
|
||||
# Read exposure from config to use in the main loop
|
||||
exposure = config.getint("video", "exposure", fallback=-1)
|
||||
|
||||
# Let the user know what's up
|
||||
print("""
|
||||
Opening a window with a test feed
|
||||
|
|
@ -193,6 +196,15 @@ try:
|
|||
if slow_mode:
|
||||
time.sleep(.5 - frame_time)
|
||||
|
||||
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.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual
|
||||
video_capture.set(cv2.CAP_PROP_EXPOSURE, float(exposure))
|
||||
|
||||
# On ctrl+C
|
||||
except KeyboardInterrupt:
|
||||
# Let the user know we're stopping
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ if fh != -1:
|
|||
# This will let the camera adjust its light levels while we're importing for faster scanning
|
||||
video_capture.grab()
|
||||
|
||||
# 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"]
|
||||
|
||||
|
|
@ -261,3 +264,12 @@ while True:
|
|||
|
||||
# End peacefully
|
||||
stop(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.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual
|
||||
video_capture.set(cv2.CAP_PROP_EXPOSURE, float(exposure))
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ device_format = v4l2
|
|||
# OPENCV only.
|
||||
force_mjpeg = false
|
||||
|
||||
# Specify exposure value explicitly. This disables autoexposure.
|
||||
# Use qv4l2 to determine an appropriate value.
|
||||
# OPENCV only.
|
||||
exposure = -1
|
||||
|
||||
[debug]
|
||||
# Show a short but detailed diagnostic report in console
|
||||
end_report = false
|
||||
|
|
|
|||
Loading…
Reference in a new issue