|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Face Detection\n", |
| 8 | + "**A real time application for face-detection.**\n", |
| 9 | + "A very simple appliation with 7 lines of code to create a face-detection application.\n", |
| 10 | + "\n", |
| 11 | + "Requires Python version 3.7 or above. Not tested with earlier versions.\n", |
| 12 | + "\n", |
| 13 | + "You will have to install the following modules if not already installed:\n", |
| 14 | + "* opencv-python\n", |
| 15 | + "* tflite for Python 3.7<br>\n", |
| 16 | + " TensorFlow Lite - Please [refer to this website](https://www.tensorflow.org/lite/guide/python) to download the appropriate version for your system, and then install it.\n", |
| 17 | + "* Xailient FaceSDK<br>\n", |
| 18 | + " Please follow the instruction on this [website to install the Xailient FaceSDK](https://sdk.xailient.com).\n", |
| 19 | + " \n", |
| 20 | + " Originally published in www.xailient.com/blog." |
| 21 | + ] |
| 22 | + }, |
| 23 | + { |
| 24 | + "cell_type": "code", |
| 25 | + "execution_count": null, |
| 26 | + "metadata": {}, |
| 27 | + "outputs": [], |
| 28 | + "source": [ |
| 29 | + "import dnn\n", |
| 30 | + "import cv2 as cv" |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "code", |
| 35 | + "execution_count": null, |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [], |
| 38 | + "source": [ |
| 39 | + "myImage = cv.imread('image.jpg')\n", |
| 40 | + "_, bboxes = dnn.FaceDetector().process_frame(myImage, threshold=0.4)" |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + "cell_type": "code", |
| 45 | + "execution_count": null, |
| 46 | + "metadata": {}, |
| 47 | + "outputs": [], |
| 48 | + "source": [ |
| 49 | + "for i in bboxes: \n", |
| 50 | + " cv.rectangle(myImage, (i[0], i[1]), (i[2], i[3]), (0, 255, 0), 3)" |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + "cell_type": "code", |
| 55 | + "execution_count": null, |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "cv.imwrite('/image_output.jpg', myImage)" |
| 60 | + ] |
| 61 | + } |
| 62 | + ], |
| 63 | + "metadata": { |
| 64 | + "kernelspec": { |
| 65 | + "display_name": "Python 3", |
| 66 | + "language": "python", |
| 67 | + "name": "python3" |
| 68 | + }, |
| 69 | + "language_info": { |
| 70 | + "codemirror_mode": { |
| 71 | + "name": "ipython", |
| 72 | + "version": 3 |
| 73 | + }, |
| 74 | + "file_extension": ".py", |
| 75 | + "mimetype": "text/x-python", |
| 76 | + "name": "python", |
| 77 | + "nbconvert_exporter": "python", |
| 78 | + "pygments_lexer": "ipython3", |
| 79 | + "version": "3.7.0" |
| 80 | + } |
| 81 | + }, |
| 82 | + "nbformat": 4, |
| 83 | + "nbformat_minor": 2 |
| 84 | +} |
0 commit comments