Deep learning enables your to Hide screens when Your Boss is approaching

Source: Internet
Author: User
Tags imagemagick keras

https://github.com/Hironsan/BossSensor/Background Introduction student age, the teacher stood outside the window of the shadow lingering. We are playing mobile phones, reading comics, reading novels, always looking for a deskmate to help see whether the class teacher has come. A blink of an eye, once the lightly moving young graduate, new troubles come, in your brush know, watch video, play mobile phone, the boss came! Don't worry, no worries, based on the latest face recognition + mobile phone push to make the bosscoming. When the boss is standing up, bosscoming will find that the boss has stood up by face recognition, and then pushed through the phone to send the notification "bosscoming", and the vibration tells you there is a situation. The effect of the truth to eat melon masses and behind the leadership: behind the leader turned around, immediately by the face recognition program found, and marked as boss: Mobile phone received push, and vibration: bosscoming: Is not like "he at the same table", with elbows kept poking you, and whispered: "The teacher came, come." Technology introduction Face Recognition technology Face_recognitiontheworld ' Ssimplestfacialrecognitionapiforpythonandthecommandlineageitgey/face_ Recognition mobile phone push technology Jpush-api-python-clientjpush ' Sofficiallysupportedpythonclientlibraryforaccessingjpushapis.jpush/jpush-api-python-client Dependent installation Pipinstallface_ Recognitionpipinstalljpush using tutorial 1. Add bossimage2. config file modify the Load_image_file parameter 3 in the Bosscoming file. Jpush is configured so that your phone can receive push. 4. You can use the demo provided by Jpush to receive notifications directly. Jpush Documentation: Jpush product Brief-Aurora documentation 5. Run the command pythonbosscoming.py experience face recognition part of the command: pythonbosswatching.py open the camera on your computer and start capturing the screen. Then adjust the angle and align to the position you want to observe. Project description by "When your boss near your seat, the face recognition technology timely screen switching" inspired, article address:, the project is bosssensor:. Because this project requires a lot of dependencies, and I run a problem, so I swapped another library to achieve. Bosscoming Project Address: The code is not perfect, only for entertainment (JUSTFORFUn!). When your boss is near your seat, face recognition technology in time screen switch hironsan/bosssensorfendouai/bosscoming reference ageitgey/face_recognitionjpush/ Jpush-api-python-clienthironsan/bosssensor Lei Feng Net press: Original author small ash, this article was originally contained in. Lei Feng Network has been authorized by the author reprint. https://baijiahao.baidu.com/po/feed/share?wfr=spider&for=pc&context=%7B%22sourceFrom%22%3A%22bjh% column 22%2c%22nid%22%3a%22news_3290793327312572388%22%7d

Introduction
When you were working, you had browsed information that isn't relevant to your work, haven ' t?

I feel awkward when my boss is creeping behind. Of course, I can switch the screen in a hurry, but such behavior is suspicious, and sometimes I don ' t notice him. So, on order to switch the screens without being suspected, I create a system that automatically recognizes that he was appr Oaching to me and hides the screen.

Specifically, Keras is used to implement neural network for learning his face, a Web camera was used to recognize that he I s approaching, and switching the screen.

Mission
The mission is-to-switch the screen automatically when my boss was approaching to me.
The situation is as follows:

It is on 6 or 7 meters from the seat to my seat. He reaches my seat in 4 or 5 seconds after he leaves his seat. Therefore, it's necessary to hide the screen during this time. There ' s not much time!

Strategy
Maybe you has various strategies, but my strategy is following.
First, let's the computer learn the face of the boss with deep learning. Then, set up a Web camera at my desk and switch the screens when the Web camera captures his face. It ' s a perfect strategy. Let's call this wonderful system Boss Sensor.

System Architecture

The simple system architecture of the Boss Sensor is as follows.

Web camera take a image in real time.
Learned model detect and recognize face for the taken image.
If The recognition result is my boss, switch screen.
The following techniques is required to do above:

Taking face image
Recognizing face image
Switching screen
Let's verify one by one and then integrate at the end.

Taking face Image
First of all, taking face image with webcam.
This time, I used BUFFALO bsw20km11bk as webcam.

You can also take image from the camera with the included software, but it's better to being able to take from the program B Ecause of considering the processing afterwards. Also, since face recognition is do in the subsequent processing, it's necessary to cut off only the face image. So, I use Python and OpenCV to take the face image. Here's the code for:

    • bosssensor/camera_reader.py

I was able to acquire a further clearly face image than I expected.

Recognizing Boss face
Next, we use machine learning so, the computer can recognize the face of the boss.
We need the following three steps:

Collecting images
Preprocessing images
Building Machine Learning Model
Let's take a look at the these one by one.

Collecting Images

First of all, I need to collect a large number of images for learning. As a collection method, I used the following:

Google Image Search
Image Collection on Facebook
Taking video
Initially, I collected images from the Web search and Facebook, but enough images do not gather. So, I took the video using a video camera and decomposed video into a large number of images.

Preprocessing Images

Well, I got a lot of images with faces, but the learning model can isn't learned as it is. This is because the "related" to the face occupies a considerable part of the image. So we cut out only the face image.

I mainly used ImageMagick for extraction. You can get only the face images by cutting off with ImageMagick.

    • ImageMagick

A large number of face images gathered as follows:

Perhaps I am the one who possesses the "face" image of the most bosses in the world. I must has it more than his parents.

Now I ' m ready for learning.

Building Machine Learning Model

Keras is used to build convolutional neural Network (CNN) and CNN are trained. TensorFlow is used for Keras's back end. If you have recognize the face and you can call the Web API for image recognition like computer Vision API in cognitive Servi CES, but this time I decided the it by myself considering real time nature.

The network has the following architecture. Keras is convenient because it can output the architecture easily.

____________________________________________________________________________________________________layer (Type ) Output Shape Param # Connected to ================================= ===================================================================convolution2d_1 (convolution2d) (None, 32, 64, ) 896 Convolution2d_input_1[0][0] ______________________________________________________________________            ______________________________activation_1 (activation) (None, 0, (+), +) convolution2d_1[0][0] ____________________________________________________________________________________________________convolution2d _2 (convolution2d) (None, +,) 9248 activation_1[0][0] ___________________________________           _________________________________________________________________activation_2 (activation) (None, 32, 62, 62) 0            CONVOLUTION2D_2[0][0]____________________________________________________________________________________________________maxpooling2d _1 (Maxpooling2d) (None, 0 activation_2[0][0] __________________________________            __________________________________________________________________dropout_1 (Dropout) (None, 32, 31, 31) 0 Maxpooling2d_1[0][0] ______________________________________________________________________________                  ______________________convolution2d_3 (convolution2d) (None, up, up) 18496 dropout_1[0][0] ____________________________________________________________________________________________________activation_ 3 (Activation) (None, 0 convolution2d_3[0][0] _________________________________ ___________________________________________________________________convolution2d_4 (convolution2d) (None, 64, 29,               ) 36928 Activation_3[0][0]____________________________________________________________________________________________________activation_ 4 (Activation) (None, 0 convolution2d_4[0][0] _________________________________    ___________________________________________________________________maxpooling2d_2 (Maxpooling2d) (None, 64, 14, 14) 0 Activation_4[0][0] ____________________________________________________________________________             ________________________dropout_2 (Dropout) (None, 0) maxpooling2d_2[0][0] ____________________________________________________________________________________________________flatten_1 ( Flatten) (None, 12544) 0 Dropout_2[0][0] _________________________________           ___________________________________________________________________dense_1 (dense) (None, 512)                  6423040 Flatten_1[0][0]____________________________________________________________________________________________________activation_ 5 (Activation) (None, 0 dense_1[0][0] _________________________________           ___________________________________________________________________dropout_3 (Dropout) (None, 512) 0 Activation_5[0][0] _____________________________________________________________________________                  _______________________dense_2 (dense) (None, 2) 1026 dropout_3[0][0] ____________________________________________________________________________________________________activation_ 6 (Activation) (None, 2) 0 Dense_2[0][0] ================================= ===================================================================total params:6489634

The code is here:

    • bosssensor/boss_train.py

So far, I can recognize the boss if he appears on the camera.

Switching screen

Now, when learned model recognize the face of the boss, I need to change the screen. In this time, let's display the image to pretend.
I am a programmer so I prepared the following image.


I only display the this image.

Since I want to display the "image in full", I use PyQt. Here's the code for:

    • bosssensor/image_show.py

Now, everything are ready.

Finished Product

Once We integrate the technologies we have verified, we is done. I actually tried it.

"My boss left his seat and he is approaching to My seat."



"OpenCV had detected the face and input the image into the learned model."

"The screen had switched by recognizing him! 's Finger licking (' ∇ ') Dentetsu??? "

Source Code

You can download Boss Sensor from following link:

    • Bosssensor

Your star encourage Me M (_ _) m

Conclusion

In this time, I combined the real-time image acquisition from a Web camera with a face recognition using Keras to recognize my Boss and hide the screen.

Currently, I detect the face with OpenCV, but since the accuracy of the face detection in OpenCV seems not good, I ' d like to t Ry using Dlib to improve the accuracy. Also I would I own trained face detection model.

Since the recognition accuracy of the image acquired from the Web camera was not good, I would like to improve it.

If you like this article, please retweet or share.↓

http://ahogrammer.com/2016/11/15/deep-learning-enables-you-to-hide-screen-when-your-boss-is-approaching/

Deep learning enables your to Hide screens when Your Boss is approaching

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.