Deep Learning Enables You to Hide Screen when Your Boss is Approaching
2017-05-07 22:14
561 查看
https://github.com/Hironsan/BossSensor/
背景介绍
学生时代,老师站在窗外的阴影挥之不去。大家在玩手机,看漫画,看小说的时候,总是会找同桌帮忙看着班主任有没有来。
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/71a825989e7d7007323ffb7fe0f20d6f)
一转眼,曾经的翩翩少年毕业了,新的烦恼来了,在你刷知乎,看视频,玩手机的时候,老板来了!
不用担心,不用着急,基于最新的人脸识别+手机推送做出的BossComing。老板站起来的时候,BossComing会通过人脸识别发现老板已经站起来,然后通过手机推送发送通知“BossComing”,并且震动告诉你有情况。
效果展示
不明真相吃瓜群众和身后领导:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/cb11a71c5018171d4794cd2a9c87bc2e)
身后领导扭头过来,马上被人脸识别程序发现,并标记为boss:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/552d7c29948060066b3caa5aa866b864)
手机收到推送,并震动:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/2312129f601185007da6b070882df41a)
BossComing:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/aa6df682941db448b829bd25ea3a7827)
是不是就像“同桌的他”,用胳膊肘不停地戳你,并且小声的说:老师来啦,来时来啦。
技术介绍
人脸识别技术
face_recognition
Theworld'ssimplestfacialrecognitionapiforPythonandthecommandline
ageitgey/face_recognition
手机推送技术
jpush-api-python-client
JPush'sofficiallysupportedPythonclientlibraryforaccessingJPushAPIs.
jpush/jpush-api-python-client
依赖安装
pipinstallface_recognition
pipinstalljpush
使用教程
1.添加bossimage
2.配置文件
修改bosscoming文件中的load_image_file参数
3.JPush配置,这样你的手机才可以收到推送。
4.可以直接使用JPush官方提供的Demo用来接收通知。
JPush文档:JPush产品简介-极光文档
5.运行命令
pythonbosscoming.py
体验人脸识别部分命令:
pythonbosswatching.py
打开电脑上摄像头,开始捕捉画面。然后调整角度,对准需要观察的位置。
项目说明
受《在你上司靠近你座位时,用人脸识别技术及时屏幕切换》启发,文章地址:,所介绍的项目是BossSensor:。因为这个项目所需要的依赖比较多,而且我运行有问题,所以换了另外一个库来实现。
BossComing项目地址:
代码还不完善,仅供娱乐(Justforfun!)。在你上司靠近你座位时,用人脸识别技术及时屏幕切换Hironsan/BossSensorfendouai/BossComing
参考引用
ageitgey/face_recognitionjpush/jpush-api-python-clientHironsan/BossSensor
雷锋网按:原作者小灰灰,本文原载于。雷锋网已获得作者授权转载。知乎专栏 https://baijiahao.baidu.com/po/feed/share?wfr=spider&for=pc&context=%7B%22sourceFrom%22%3A%22bjh%22%2C%22nid%22%3A%22news_3290793327312572388%22%7D Introduction
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.
Mission
The mission is to switch the screen automatically when my boss is approaching to me.
The situation is as follows:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/c26603a4e9da49c14ec990dda7e25a97.png)
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!
Strategy
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.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/92bf05e33dd954151ed71e61957f9dd1.png)
System Architecture
The simple system architecture of the Boss Sensor is as follows.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/20bb0e0dc9d0cdee2eb6f26a075cb4d3.png)
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.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/613ba1725ee875520d857057647203ca.jpg)
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:
BossSensor/camera_reader.py
I was able to acquire a more clearly face image than I expected.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/2e5bf287c51cb4137101fe386fbf321b.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:
Collecting images
Preprocessing images
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.
ImageMagick
A large number of face images gathered as follows:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/8f2ed4a2d3cca26cfeca79dce66d18a5.jpg)
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.
The code is here:
BossSensor/boss_train.py
So far, I can recognize the boss when he appears on the camera.
I am a programmer so I prepared the following image.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/26403bde0ce5fd99f72fba0b02181418.png)
I only display this image.
Since I want to display the image in full screen, I use PyQt. Here’s the code for that:
BossSensor/image_show.py
Now, everything is ready.
“My boss left his seat and he was approaching to my seat.”
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/4c7bcf7c159690ce17d39e694038148c.jpg)
“OpenCV has detected the face and input the image into the learned model.”
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/bf40e008470522b99067cf8ff7e9d46d.jpg)
“The screen has switched by recognizing him! ヽ(‘ ∇‘ )ノ ワーイ”
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/ad99cb5369a165fec27b80b0fd6a1849.jpg)
BossSensor
Your star encourage me m(_ _)m
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.↓
http://ahogrammer.com/2016/11/15/deep-learning-enables-you-to-hide-screen-when-your-boss-is-approaching/
背景介绍
学生时代,老师站在窗外的阴影挥之不去。大家在玩手机,看漫画,看小说的时候,总是会找同桌帮忙看着班主任有没有来。
一转眼,曾经的翩翩少年毕业了,新的烦恼来了,在你刷知乎,看视频,玩手机的时候,老板来了!
不用担心,不用着急,基于最新的人脸识别+手机推送做出的BossComing。老板站起来的时候,BossComing会通过人脸识别发现老板已经站起来,然后通过手机推送发送通知“BossComing”,并且震动告诉你有情况。
效果展示
不明真相吃瓜群众和身后领导:
身后领导扭头过来,马上被人脸识别程序发现,并标记为boss:
手机收到推送,并震动:
BossComing:
是不是就像“同桌的他”,用胳膊肘不停地戳你,并且小声的说:老师来啦,来时来啦。
技术介绍
人脸识别技术
face_recognition
Theworld'ssimplestfacialrecognitionapiforPythonandthecommandline
ageitgey/face_recognition
手机推送技术
jpush-api-python-client
JPush'sofficiallysupportedPythonclientlibraryforaccessingJPushAPIs.
jpush/jpush-api-python-client
依赖安装
pipinstallface_recognition
pipinstalljpush
使用教程
1.添加bossimage
2.配置文件
修改bosscoming文件中的load_image_file参数
3.JPush配置,这样你的手机才可以收到推送。
4.可以直接使用JPush官方提供的Demo用来接收通知。
JPush文档:JPush产品简介-极光文档
5.运行命令
pythonbosscoming.py
体验人脸识别部分命令:
pythonbosswatching.py
打开电脑上摄像头,开始捕捉画面。然后调整角度,对准需要观察的位置。
项目说明
受《在你上司靠近你座位时,用人脸识别技术及时屏幕切换》启发,文章地址:,所介绍的项目是BossSensor:。因为这个项目所需要的依赖比较多,而且我运行有问题,所以换了另外一个库来实现。
BossComing项目地址:
代码还不完善,仅供娱乐(Justforfun!)。在你上司靠近你座位时,用人脸识别技术及时屏幕切换Hironsan/BossSensorfendouai/BossComing
参考引用
ageitgey/face_recognitionjpush/jpush-api-python-clientHironsan/BossSensor
雷锋网按:原作者小灰灰,本文原载于。雷锋网已获得作者授权转载。知乎专栏 https://baijiahao.baidu.com/po/feed/share?wfr=spider&for=pc&context=%7B%22sourceFrom%22%3A%22bjh%22%2C%22nid%22%3A%22news_3290793327312572388%22%7D Introduction
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.
Mission
The mission is to switch the screen automatically when my boss is approaching to me.
The situation is as follows:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/c26603a4e9da49c14ec990dda7e25a97.png)
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!
Strategy
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.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/92bf05e33dd954151ed71e61957f9dd1.png)
System Architecture
The simple system architecture of the Boss Sensor is as follows.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/20bb0e0dc9d0cdee2eb6f26a075cb4d3.png)
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.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/613ba1725ee875520d857057647203ca.jpg)
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:
BossSensor/camera_reader.py
I was able to acquire a more clearly face image than I expected.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/2e5bf287c51cb4137101fe386fbf321b.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:
Collecting images
Preprocessing images
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.
ImageMagick
A large number of face images gathered as follows:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/8f2ed4a2d3cca26cfeca79dce66d18a5.jpg)
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:
BossSensor/boss_train.py
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.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/26403bde0ce5fd99f72fba0b02181418.png)
I only display this image.
Since I want to display the image in full screen, I use PyQt. Here’s the code for that:
BossSensor/image_show.py
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.”
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/4c7bcf7c159690ce17d39e694038148c.jpg)
“OpenCV has detected the face and input the image into the learned model.”
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/bf40e008470522b99067cf8ff7e9d46d.jpg)
“The screen has switched by recognizing him! ヽ(‘ ∇‘ )ノ ワーイ”
![](https://oscdn.geek-share.com/Uploads/Images/Content/201705/ad99cb5369a165fec27b80b0fd6a1849.jpg)
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 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.↓
http://ahogrammer.com/2016/11/15/deep-learning-enables-you-to-hide-screen-when-your-boss-is-approaching/
相关文章推荐
- Deep Learning Enables You to Hide Screen when Your Boss is Approaching
- How to use Deep Learning when you have Limited Data
- 133 You want to enable automatic PGA memory management in your database. Which setting is required t
- Is your boss making you sick?
- 【学习笔记】WEEK 1_Introduction to Deep Learning_Why is Deep Learning taking off?
- The source file is different from when the module was built. Would you like the debugger to use it anyway?
- 72.You want to enable archiving on your database. Presently, the database is running in NOARCHIVELOG
- 打开OpenProj 出现Your Java Vendor is "Oracle Corporation". To run OpenProj, you need the Sun Java...
- PHP入门Demo(只为前端了解)When you really want to know a thing, You will see is really very simple.
- (转)The 9 Deep Learning Papers You Need To Know About (Understanding CNNs Part 3)
- 【学习笔记】WEEK 1_Introduction to Deep Learning_What is a neural network?
- Your Progress As A Programmer Is All Up To You
- I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum o
- The 9 Deep Learning Papers You Need To Know About (Understanding CNNs Part 3)
- 【转载】How to build and run your first deep learning network
- 【Windows Phones 7】Ready for take-off? Top 10 things to check when you think you are done with your application.
- The 9 Deep Learning Papers You Need To Know About (Understanding CNNs Part 3)
- 138 Your database instance is running. You are not able to access Oracle Enterprise Manager Database
- Code view is missing in SharePoint Designer Beta 2 when you try to edit a WSS v3 site.
- If you have multiple web application run how to determin which is yours when you debug using visual studio 2008?