-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: qr_reader_pc crate: opencv video input and output (#873)
* rscam replaced by nokhwa (crossplatform video capture) crate. Added video output using minifb crate. * Program argument processing added. Added display of the list of available devices. * Improved parser of program arguments. * Program argument parser improvements. Added structure for camera config storing. * Argument parser refactoring. * Documentation added. * implementation with opencv * QR decoding added. Extra code removed. Documentation updated. * Quircs crate returned (due to problems with the opencv QR decoder). Unit and integration tests added. QR decoding function added to API. * Readme file updated. * Opencv version update. Extra dependencies are removed. * Doc fix. * fix: remove extra spaces and add line break * fix: crate version 0.2.0 * fix: skipping frames to prevent cpaturing old frames from the camera buffer Co-authored-by: Slesarew <[email protected]>
- Loading branch information
Showing
6 changed files
with
285 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
[package] | ||
name = "qr_reader_pc" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = ["vera"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
hex = "0.4.3" | ||
rscam = "0.5.5" | ||
image = "0.23.14" | ||
raptorq = "1.6.4" | ||
qr_reader_phone = {path = "../qr_reader_phone"} | ||
quircs = "0.10.0" | ||
anyhow = "1.0.42" | ||
image = "0.23.14" | ||
quircs = "0.10.0" | ||
|
||
[dependencies.opencv] | ||
version = "0.60" | ||
default-features = false | ||
features = ["clang-runtime", "videoio", "imgproc", "highgui"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# QR reader crate for PC | ||
|
||
QR reader crate for PC is a utility to capture (via webcam) QR codes from Signer mobile app | ||
and extracting data from it. | ||
It prints a string with decoded QR message in HEX format on display (and to file "decoded_output.txt"). | ||
|
||
## Getting Started | ||
|
||
### Dependencies | ||
|
||
The main requirement is the OpenCV. You can check this manuals: https://crates.io/crates/opencv and https://docs.opencv.org. | ||
|
||
#### Arch Linux: | ||
|
||
OpenCV package in Arch is suitable for this crate. It requires some dependencies. | ||
|
||
* `pacman -S clang qt5-base opencv` | ||
|
||
#### Other Linux systems: | ||
|
||
* For Debian/Ubuntu also you need: `clang` and `libclang-dev` | ||
* For Gentoo/Fedora also you need: `clang` | ||
* It is preferable to build latest version of opencv+opencv_contrib from source. OpenCV package from the system repository may not contain the necessary libraries.\ | ||
Use this manual: https://docs.opencv.org/4.5.3/d7/d9f/tutorial_linux_install.html | ||
|
||
### Executing program | ||
|
||
* Run the program: `cargo run` + arguments | ||
* Press any key to stop | ||
|
||
#### Arguments | ||
|
||
* `d` | `-d` | `--device` : set index of camera (from list of available cameras) | ||
* `l` | `-l` | `--list` : get a list of available camera indexes | ||
* `h` | `-h` | `--help` : refers to this manual | ||
|
||
Camera resolution is hardcoded (640x480). | ||
|
||
#### Examples | ||
|
||
* `cargo run d 0` (camera index = 0) | ||
* `cargo run l` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
use qr_reader_pc::run_with_camera; | ||
use qr_reader_pc::{arg_parser, run_with_camera}; | ||
use std::env; | ||
|
||
fn main() { | ||
match run_with_camera() { | ||
Ok(line) => println!("Success! {}", line), | ||
Err(e) => println!("Error. {}", e), | ||
|
||
fn main() -> Result<(), String> { | ||
|
||
let arguments = env::args().collect(); | ||
|
||
let camera_settings = match arg_parser(arguments) { | ||
Ok(x) => x, | ||
Err(e) => return Err(format!("{}", e)), | ||
}; | ||
|
||
match run_with_camera(camera_settings) { | ||
Ok(line) => println!("Result HEX: {}", line), | ||
Err(e) => return Err(format!("QR reading error. {}", e)), | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.