Deep Learning Enables You to Hide Screen when Your Boss is Approaching


When you are working, you have browsed information that is not relevant to your work, haven’t you?

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, in order to switch the screen without being suspected, I create a system that automatically recognizes that he is approaching to me and hides the screen.

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


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

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


Maybe you have various strategies, but my strategy is following.
First, let the computer learn the face of the boss with deep learning. Then, set up a web camera at my desk and switch the screen 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 an 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 are required to do above:

  • Taking face image
  • Recognizing face image
  • Switching screen

Let’s verify one by one, 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 is better to be able to take from the program because of considering the processing afterwards. Also, since face recognition is done in the subsequent processing, it is necessary to cut out only the face image. So, I use Python and OpenCV to take face image. Here’s the code for that:

I was able to acquire a more clearly face image than I expected.
スクリーンショット 2016-09-15 9.49.32.png

Recognizing Boss Face

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

  1. Collecting images
  2. Preprocessing images
  3. Building Machine Learning Model

Let’s take a look at 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 Web search and Facebook, but enough images did not gather. So, I took 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 not be learned as it is. This is because the part not 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 face images by cutting out with ImageMagick.

A large number of face images gathered as follows:

Perhaps I am the one who possesses the face image of the most boss in the world. I must have 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 is trained. TensorFlow is used for Keras’s back end. If you only recognize the face, you can call the Web API for image recognition like Computer Vision API in Cognitive Services, but this time I decided to make 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, 64)    896         convolution2d_input_1[0][0]      
activation_1 (Activation)        (None, 32, 64, 64)    0           convolution2d_1[0][0]            
convolution2d_2 (Convolution2D)  (None, 32, 62, 62)    9248        activation_1[0][0]               
activation_2 (Activation)        (None, 32, 62, 62)    0           convolution2d_2[0][0]            
maxpooling2d_1 (MaxPooling2D)    (None, 32, 31, 31)    0           activation_2[0][0]               
dropout_1 (Dropout)              (None, 32, 31, 31)    0           maxpooling2d_1[0][0]             
convolution2d_3 (Convolution2D)  (None, 64, 31, 31)    18496       dropout_1[0][0]                  
activation_3 (Activation)        (None, 64, 31, 31)    0           convolution2d_3[0][0]            
convolution2d_4 (Convolution2D)  (None, 64, 29, 29)    36928       activation_3[0][0]               
activation_4 (Activation)        (None, 64, 29, 29)    0           convolution2d_4[0][0]            
maxpooling2d_2 (MaxPooling2D)    (None, 64, 14, 14)    0           activation_4[0][0]               
dropout_2 (Dropout)              (None, 64, 14, 14)    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, 512)           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:

So far, I can recognize the boss when 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 to work.
I am a programmer so I prepared the following image.


I only display this image.

Since I want to display the image in full screen, I use PyQt. Here’s the code for that:

Now, everything is ready.

Finished Product

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

“My boss left his seat and he was approaching to my seat.”

“OpenCV has detected the face and input the image into the learned model.”

“The screen has switched by recognizing him! ヽ(‘ ∇‘ )ノ ワーイ”

Source Code

You can download Boss Sensor from following link:

Your star encourage me m(_ _)m


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

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

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

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

52 thoughts on “Deep Learning Enables You to Hide Screen when Your Boss is Approaching

  1. Seungju Choi Reply

    Very interesting!
    if your boss saw this post, then the project would be failed. even through There is improvement of recognition. 🙂

  2. batmandevelops Reply

    I find it difficult even when someone else is snooping into my screen, why only my boss. I think basic face detection can also solve the problem 😛

  3. Kristen Reply

    I will right away take hold of your rss feed as I can’t
    find your e-mail subscription link or newsletter service.
    Do you’ve any? Kindly permit me understand so
    that I may just subscribe. Thanks.

  4. Jason Reply

    I have been browsing on-line more than three hours
    these days, but I never discovered any interesting article like yours.
    It’s pretty value sufficient for me. In my opinion, if all web owners and bloggers
    made just right content material as you did,
    the internet will probably be a lot more useful than ever before.

  5. Kill Reply

    I will right away grasp your rss feed as I can not to find your
    email subscription hyperlink or e-newsletter service.

    Do you have any? Please allow me understand in order that I could
    subscribe. Thanks.

  6. Robert Reply

    What if your boss comes from another direction? Or looks over the cubes behind you? Most companies have key loggers installed, plus they can check the DNS log. Nice project, but not practical in the real world. Most people sit sideways in their cube, and have a small laptop at the entrance turned sideways so no one can see it. People hate having their back turned to the isle.

  7. muscle village Reply

    Hi there to every one, the contents present at this site are truly amazing for people experience, well,
    keep up the nice work fellows.

  8. Pingback: [Blog Reads] December 2016 – January 2017 – Cathartic Student

  9. stefan Reply

    Nice approach. You will need another, better library for face recognition or better learning algorithm. Anyway, I see potential in your project and hope you will fix all your issues.

  10. grant money Reply

    That is very fascinating, You’re an excessively skilled blogger.
    I have joined your rss feed and sit up for seeking extra of
    your wonderful post. Additionally, I’ve shared your website in my
    social networks

  11. Sun Reply

    Like your article very much,thank you for sharing the spirit, and this article give us an interesting reading experience.

    May I ask you to translate this article into Chinese, please be assured, I will not be use it for business, and I’m sure that i will retain the original link.

    Finally, thanks again.

    Best Regard.

    • Jcme丶Ls Reply

      Hello SUN,

      I am also interested in translating and parsing this system. TensorFlow recently in the study, and also learning Keras framework, do not know if you have completed the translation, if not completed, then I will translate and look forward to your reply.

      Best Regard.

  12. muscle village Reply

    I’m extremely inspired with your writing abilities
    as neatly as with the format on your blog. Is that this a paid subject or did you customize it your self?

    Either way stay up the nice quality writing, it is rare to
    see a great blog like this one today..

  13. 高清连续剧 Reply

    I really like what you guys tend to be up too.
    This type of clever work and exposure! Keep up the very good works guys I’ve incorporated you guys to
    my own blogroll.

  14. Johnd281 Reply

    I’m trying to find sites that have already fantastic useful information on what’s popular and what is the optimum makeup products is.. dgebeefkekfd

  15. 电视剧网 Reply

    I feel this is one of the such a lot vital information for me.

    And i am satisfied reading your article. But wanna remark on few normal things, The web site style
    is wonderful, the articles is really nice : D.
    Excellent task, cheers

  16. Leilani Serdán Reply

    OMG!! It is so interesting but at the same time you made me laugh!!! I love it!!

  17. Johne393 Reply

    Some genuinely prize content on this internet site, bookmarked. fcefebdkkacd

    • Hironsan Post authorReply

      Actually, my boss have already known BossSensor.

      When I told him about it, he laughed and tell me “Improve it!”

  18. Kenny Yeo Reply

    Great work! It is usually these kinds of small things in life that inspires the greatest invention!

  19. Jcme丶Ls Reply

    Hi Hironsan,

    Thank you so much for your idea and realization.
    I am a TensorFlow learner. At the same time I was studying Keras lately. I want to parse the system, write the tutorial and put it on my blog. Can you authorize me?

    Best Regard.

    • Hironsan Post authorReply

      Sure! If you complete, tell me about it.
      I am looking forward to that.

      • Jcme丶Ls Reply

        Thank you very much!
        I will sort out as soon as possible. But the recent Chinese New Year, the tutorial may be delayed.

  20. philip Reply

    so on the off chance you are actually do what you are meant to be doing, and he comes along does the screen still switch, ie, switch to what you were hiding in the first place? lol

  21. hongwoo jin Reply

    You looked utlized web cam implemented around you, but if I want use embedded web cam on laptop, is it working similar results?

Leave a Reply

Your email address will not be published. Required fields are marked *