From a061b5cc86b9e58e3e488e2e486a6b677b5c5f55 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Sat, 2 Feb 2019 13:36:00 +0100 Subject: [PATCH 1/9] Readme update --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d216bb8..4ed4f16 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Howdy for Linux [![](https://img.shields.io/travis/boltgolt/howdy/master.svg)](https://travis-ci.org/boltgolt/howdy) [![](https://img.shields.io/github/release/boltgolt/howdy.svg?colorB=4c1)](https://github.com/boltgolt/howdy/releases) +# Howdy for Linux [![](https://img.shields.io/travis/boltgolt/howdy/master.svg)](https://travis-ci.org/boltgolt/howdy) [![](https://img.shields.io/github/release/boltgolt/howdy.svg?colorB=4c1)](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. +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. @@ -29,7 +29,7 @@ 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: +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 +38,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,17 +57,17 @@ 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 | | `test` | Test the camera and recognition methods | -## Contributing [![](https://img.shields.io/travis/boltgolt/howdy/dev.svg?label=dev%20build)](https://github.com/boltgolt/howdy/tree/dev) [![](https://img.shields.io/github/issues-raw/boltgolt/howdy/enhancement.svg?label=feature+requests&colorB=4c1)](https://github.com/boltgolt/howdy/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) +## Contributing [![](https://img.shields.io/travis/boltgolt/howdy/dev.svg?label=dev%20build)](https://github.com/boltgolt/howdy/tree/dev) [![](https://img.shields.io/github/issues-raw/boltgolt/howdy/enhancement.svg?label=feature+requests&colorB=4c1)](https://github.com/boltgolt/howdy/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) [![](https://img.shields.io/badge/endpoint.svg?url=https://boltgolt.nl/howdy/shield.json)](https://www.buymeacoffee.com/boltgolt) 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 +77,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. + + From ab3c730c3a55ad8b8888b7667b1adcfc0169b9bb Mon Sep 17 00:00:00 2001 From: boltgolt Date: Tue, 5 Feb 2019 16:51:13 +0100 Subject: [PATCH 2/9] Added new logo into the readme --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ed4f16..cf47490 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ -# Howdy for Linux [![](https://img.shields.io/travis/boltgolt/howdy/master.svg)](https://travis-ci.org/boltgolt/howdy) [![](https://img.shields.io/github/release/boltgolt/howdy.svg?colorB=4c1)](https://github.com/boltgolt/howdy/releases) +![](https://boltgolt.nl/howdy/banner.png) + +

+ + + + + + + + + + + + +

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. @@ -29,6 +44,8 @@ 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 +_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: ``` @@ -63,7 +80,7 @@ howdy [-U user] [-y] command [argument] | `remove` | Remove a specific model for an user | | `test` | Test the camera and recognition methods | -## Contributing [![](https://img.shields.io/travis/boltgolt/howdy/dev.svg?label=dev%20build)](https://github.com/boltgolt/howdy/tree/dev) [![](https://img.shields.io/github/issues-raw/boltgolt/howdy/enhancement.svg?label=feature+requests&colorB=4c1)](https://github.com/boltgolt/howdy/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) [![](https://img.shields.io/badge/endpoint.svg?url=https://boltgolt.nl/howdy/shield.json)](https://www.buymeacoffee.com/boltgolt) +## Contributing [![](https://img.shields.io/travis/boltgolt/howdy/dev.svg?label=dev%20build)](https://github.com/boltgolt/howdy/tree/dev) [![](https://img.shields.io/github/issues-raw/boltgolt/howdy/enhancement.svg?label=feature+requests&colorB=4c1)](https://github.com/boltgolt/howdy/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) 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). From 72801b947fbb069861c86c4a848088a198ccf4c2 Mon Sep 17 00:00:00 2001 From: Riley Carpenter <31159790+rileyball@users.noreply.github.com> Date: Wed, 27 Feb 2019 11:54:38 -0500 Subject: [PATCH 3/9] Change Debian to Ubuntu Debian can't use PPAs so saying that you install this on debian like that is misleading --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf47490..128b87f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Howdy is currently available for Debian/Ubuntu, Arch Linux and Fedora. If you’ **Note:** The build of dlib can hang on 100% for over a minute, give it time. -### Debian (Ubuntu, Linux Mint, etc) +### Ubuntu (Ubuntu, Linux Mint, etc) Run the installer by pasting (`ctrl+shift+V`) the following commands into the terminal one at a time: From 5604f5f43203ff856de513dbd2e0d61022109d8c Mon Sep 17 00:00:00 2001 From: Riley Carpenter <31159790+rileyball@users.noreply.github.com> Date: Wed, 27 Feb 2019 20:03:09 -0500 Subject: [PATCH 4/9] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 128b87f..271be2e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Howdy is currently available for Debian/Ubuntu, Arch Linux and Fedora. If you’ **Note:** The build of dlib can hang on 100% for over a minute, give it time. -### Ubuntu (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: @@ -37,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). From 19aac39c759178366e5b13b9812db7642bc2a269 Mon Sep 17 00:00:00 2001 From: Anthony Wharton Date: Fri, 1 Mar 2019 22:14:50 +0000 Subject: [PATCH 5/9] Add current AUR PKGBUILD --- archlinux/PKGBUILD | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 archlinux/PKGBUILD diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD new file mode 100644 index 0000000..1835294 --- /dev/null +++ b/archlinux/PKGBUILD @@ -0,0 +1,88 @@ +# Maintainer: boltgolt +# Maintainer: Kelley McChesney +pkgname=howdy +pkgver=2.3.1 +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.3.1.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=('d4057fd4f27c1d14e30718e9412eac578b383846d70cbb7a57725d8132c90b1e' + '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-2.3.1 + 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" +} From 70c92a3fd6859387ba30e9be5d8b531463088597 Mon Sep 17 00:00:00 2001 From: Anthony Wharton Date: Fri, 1 Mar 2019 22:16:06 +0000 Subject: [PATCH 6/9] Update Arch Linux AUR PKGBUILD to 2.5.0 --- archlinux/PKGBUILD | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index 1835294..e562913 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: boltgolt # Maintainer: Kelley McChesney pkgname=howdy -pkgver=2.3.1 +pkgver=2.5.0 pkgrel=1 pkgdesc="Windows Hello for Linux" arch=('x86_64') @@ -25,11 +25,11 @@ makedepends=( 'python-pip' ) backup=('usr/lib/security/howdy/config.ini') -source=("https://github.com/boltgolt/howdy/archive/v2.3.1.tar.gz" +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=('d4057fd4f27c1d14e30718e9412eac578b383846d70cbb7a57725d8132c90b1e' +sha256sums=('a42c278f05866a6a616e8f5dd8349e35769063a229c236e680e566c5a6580334' '0ef4dda35da14088afb1640266415730a6e0274bea934917beb5aca90318f853' 'acb9d1b5cf7cad73d5524334b7954431bb9b90f960980378c538907e468c34b5' '02dd9a4d8ec921ff9a2408183f290f08102e3f9e0151786ae7220a4d550bfe24') @@ -37,7 +37,7 @@ prepare() { # Preparing dlib with GPU here git clone --depth 1 https://github.com/davisking/dlib.git dlib_clone - # Preparing pam-python to be installed + # 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 @@ -45,7 +45,7 @@ prepare() { 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 @@ -75,7 +75,7 @@ package() { cd .. # Installing the proper license files and the rest of howdy - cd howdy-2.3.1 + 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" From b3a5df9cf3a946951019862eee68a47732efffaa Mon Sep 17 00:00:00 2001 From: Anthony Wharton Date: Sat, 2 Mar 2019 15:27:20 +0000 Subject: [PATCH 7/9] Add missing .SRCINFO to archlinux files --- archlinux/.SRCINFO | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 archlinux/.SRCINFO diff --git a/archlinux/.SRCINFO b/archlinux/.SRCINFO new file mode 100644 index 0000000..8002aed --- /dev/null +++ b/archlinux/.SRCINFO @@ -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 + From 0c4992ffaf51e281a7c11e2dfd66aa71de85fec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Aceda=C5=84ski?= Date: Mon, 11 Mar 2019 00:21:54 +0100 Subject: [PATCH 8/9] Manual exposure support for OpenCV --- src/cli/test.py | 11 +++++++++++ src/compare.py | 11 +++++++++++ src/config.ini | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/src/cli/test.py b/src/cli/test.py index c3cbebb..346e465 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -37,6 +37,17 @@ if fw != -1: if fh != -1: video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, fh) +# Disable autoexposure +exposure = config.getint("video", "exposure", fallback=-1) +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. + for i in range(6): + video_capture.grab() + video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual + video_capture.set(cv2.CAP_PROP_EXPOSURE, 167.0) + # Let the user know what's up print(""" Opening a window with a test feed diff --git a/src/compare.py b/src/compare.py index 3f472b8..97d1027 100644 --- a/src/compare.py +++ b/src/compare.py @@ -144,6 +144,17 @@ if fh != -1: # This will let the camera adjust its light levels while we're importing for faster scanning video_capture.grab() +# Disable autoexposure +exposure = config.getint("video", "exposure", fallback=-1) +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. + for i in range(5): + video_capture.grab() + video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual + video_capture.set(cv2.CAP_PROP_EXPOSURE, 167.0) + # Note the time it took to open the camera timings["ic"] = time.time() - timings["ic"] diff --git a/src/config.ini b/src/config.ini index 34d5685..c306410 100644 --- a/src/config.ini +++ b/src/config.ini @@ -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 From f1678de32424810ef12d5e8afd084463c376579e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Aceda=C5=84ski?= Date: Mon, 11 Mar 2019 23:30:31 +0100 Subject: [PATCH 9/9] Set exposure in the main loop and at every frame --- src/cli/test.py | 19 ++++++++++--------- src/compare.py | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/cli/test.py b/src/cli/test.py index 346e465..b748140 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -37,16 +37,8 @@ if fw != -1: if fh != -1: video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, fh) -# Disable autoexposure +# Read exposure from config to use in the main loop exposure = config.getint("video", "exposure", fallback=-1) -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. - for i in range(6): - video_capture.grab() - video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual - video_capture.set(cv2.CAP_PROP_EXPOSURE, 167.0) # Let the user know what's up print(""" @@ -204,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 diff --git a/src/compare.py b/src/compare.py index 97d1027..17ac2a7 100644 --- a/src/compare.py +++ b/src/compare.py @@ -144,16 +144,8 @@ if fh != -1: # This will let the camera adjust its light levels while we're importing for faster scanning video_capture.grab() -# Disable autoexposure +# Read exposure from config to use in the main loop exposure = config.getint("video", "exposure", fallback=-1) -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. - for i in range(5): - video_capture.grab() - video_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual - video_capture.set(cv2.CAP_PROP_EXPOSURE, 167.0) # Note the time it took to open the camera timings["ic"] = time.time() - timings["ic"] @@ -272,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))