|
| 1 | +# Smart Library Demo |
| 2 | +The applicattion is a demo of automated “smart library”. |
| 3 | +It involves the registration of the reader; authorization of the reader through face recognition; |
| 4 | +receiving and returning books by recognizing QR codes generated for each book in the library. |
| 5 | +The following pretrained models can be used: |
| 6 | + |
| 7 | +* `face-detection-retail-0004`, to detect faces and predict their bounding boxes; |
| 8 | +* `landmarks-regression-retail-0009`, to predict face keypoints; |
| 9 | +* `face-reidentification-retail-0095`, to recognize readers. |
| 10 | + |
| 11 | +For more information about the pre-trained models, refer to the [model documentation](../../../models/intel/index.md). |
| 12 | + |
| 13 | +### How it works |
| 14 | + |
| 15 | +The application is started from command line. It accepted several parameters. |
| 16 | +It reads video stream frame-by-frame from a web-camera device and performs independent analysis |
| 17 | +of each frame. To make predictions the application using 3 models. An input frame is processed by |
| 18 | +the face detection model to predict face bounding boxes. Then, face keypoints |
| 19 | +are predicted by the facial landmarks regression model. Keypoints are using |
| 20 | +to align the face and match it with face in data base. |
| 21 | +To register in library press `r` on keyboard. Once reader has beeen registered, he will be autothorized |
| 22 | +through face recognition. Registration allows to receiving and ruturning books by recognizing QR codes for |
| 23 | +each book. To make book recognition press `b` on keyboard. Also applications provides some |
| 24 | +extra statictics in console, like list of registered readers, full list of books in the library, |
| 25 | +hystory of borrowing books. To change information in console press `f` on keyboard. To exit press `q`. |
| 26 | + |
| 27 | +### Creating QR-codes for books |
| 28 | +Next two files are using to create QR-codes for books: |
| 29 | +`library.json` file contains information about books in the library. |
| 30 | +`createQRCodes.py` script generates QR-codes for each book in `library.json` file. |
| 31 | + |
| 32 | +usage: createQRCodes.py [-h] [-i LIB] [-o OUT] |
| 33 | + |
| 34 | +optional arguments: |
| 35 | + -h, --help show this help message and exit |
| 36 | + -i LIB unput `.json` file with info |
| 37 | + -o OUT directory to save generated QR-codes |
| 38 | + |
| 39 | +### Installation and dependencies |
| 40 | + |
| 41 | +The demo depends on: |
| 42 | +- OpenVINO toolkit (2019R3 or newer) |
| 43 | +- Python (any of 2.7+ or 3.4+, which is supported by OpenVINO) |
| 44 | +- OpenCV (>=3.4.0) |
| 45 | + |
| 46 | +To install all the required Python modules you can use: |
| 47 | + |
| 48 | +pip install -r requirements.txt |
| 49 | + |
| 50 | + |
| 51 | +### Running the demo: |
| 52 | + |
| 53 | +Running the application with the `-h` option or without |
| 54 | +any arguments yields the following message: |
| 55 | + |
| 56 | +``` sh |
| 57 | +python ./smart_library_demo.py -h |
| 58 | + |
| 59 | +usage: smart_library_demo.py [-h] -reid RDDET -m_rd RDMODEL -fd FDDET -m_fd |
| 60 | + FDMODEL -lm LMDET -m_lm LMMODEL [-w_rd RDWIDTH] |
| 61 | + [-h_rd RDHEIGHT] [-t_rd RDTHRESHOLD] |
| 62 | + [-w_fd FDWIDTH] [-h_fd FDHEIGHT] |
| 63 | + [-t_fd FDTHRESHOLD] [-w_lm LMWIDTH] |
| 64 | + [-h_lm LMHEIGHT] [-br BR] [-lib LIB] [-w WEB] |
| 65 | + |
| 66 | +Smart Library Sample |
| 67 | + |
| 68 | +Optional arguments: |
| 69 | + -h, --help show this help message and exit |
| 70 | + -w_rd RDWIDTH Optional. Image width to resize |
| 71 | + -h_rd RDHEIGHT Optional. Image height to resize |
| 72 | + -t_rd RDTHRESHOLD Optional. Probability threshold for face detections. |
| 73 | + -w_fd FDWIDTH Optional. Image width to resize |
| 74 | + -h_fd FDHEIGHT Optional. Image height to resize |
| 75 | + -t_fd FDTHRESHOLD Optional. Probability threshold for face detections. |
| 76 | + -w_lm LMWIDTH Optional. Image width to resize |
| 77 | + -h_lm LMHEIGHT Optional. Image height to resize |
| 78 | + -br BR Optional. Type - QR |
| 79 | + -lib LIB Optional. Path to library. |
| 80 | + -w WEB Optional. Specify index of web-camera to open. Default is |
| 81 | + 0 |
| 82 | + |
| 83 | +Models: |
| 84 | + -reid RDDET Required. Type of recognizer. Available DNN face |
| 85 | + recognizer - DNNfr |
| 86 | + -m_rd RDMODEL Required. Path to .xml file |
| 87 | + -fd FDDET Required. Type of detector. Available DNN face detector - |
| 88 | + DNNfd |
| 89 | + -m_fd FDMODEL Required. Path to .xml file |
| 90 | + -lm LMDET Required. Type of detector. Available DNN landmarks |
| 91 | + regression - DNNlm |
| 92 | + -m_lm LMMODEL Required. Path to .xml file |
| 93 | + |
| 94 | + |
| 95 | +Example of a valid command line to run the application: |
| 96 | + |
| 97 | +Linux (`sh`, `bash`, ...) (assuming OpenVINO installed in `/opt/intel/openvino`): |
| 98 | + |
| 99 | +``` sh |
| 100 | +# Set up the environment |
| 101 | +source /opt/intel/openvino/bin/setupvars.sh |
| 102 | +
|
| 103 | +python ./smart_library_demo.py \ |
| 104 | +-reid='DNNfr' \ |
| 105 | +-m_rd=<path_to_model>/face-reidentification-retail-0095.xml \ |
| 106 | +-fd='DNNfd' -m_fd=<path_to_model>/face-detection-retail-0004.xml \ |
| 107 | +-lm='DNNlm' \ |
| 108 | +-m_lm=<path_to_model>/landmarks-regression-retail-0009.xml \ |
| 109 | +``` |
| 110 | + |
| 111 | +Windows (`cmd`, `powershell`) (assuming OpenVINO installed in `C:/Program Files (x86)/IntelSWTools/openvino/`): |
| 112 | + |
| 113 | +``` powershell |
| 114 | +# Set up the environment |
| 115 | +call C:/Program Files (x86)/IntelSWTools/openvino_2019.3.334/bin/setupvars.bat |
| 116 | +
|
| 117 | +python smart_library_demo.py -reid='DNNfr' -m_rd=<path_to_model>/face-reidentification-retail-0095.xml |
| 118 | + -fd='DNNfd' -m_fd=<path_to_model>/face-detection-retail-0004.xml |
| 119 | + -lm='DNNlm' -m_lm=<path_to_model>/landmarks-regression-retail-0009.xml |
| 120 | +
|
| 121 | +Notice that the custom networks should be converted to the |
| 122 | +Inference Engine format (*.xml + *bin) first. To do this use the |
| 123 | +[Model Optimizer](https://software.intel.com/en-us/articles/OpenVINO-ModelOptimizer) tool. |
| 124 | +
|
| 125 | +### Demo output |
| 126 | +
|
| 127 | +The demo uses OpenCV window to display the resulting video frame and detections. |
| 128 | +It outputs logs to the terminal. |
| 129 | +
|
| 130 | +## See also |
| 131 | +* [Using Inference Engine Demos](../../README.md) |
0 commit comments