(OpenCV/Keras)用手势控制的计算器

2018 年 3 月 4 日 机器学习研究会
                                                                                                                                                                                       
点击上方 “机器学习研究会”可以订阅
摘要
 

转自:爱可可-爱生活

A gesture controlled calculator.

Note

If you are looking for a program that can recognize the 26 alphabets of the American Sign Language then visit here.

Outcome

Check it out here in this video

Requirements

  1. OpenCV

  2. Numpy

  3. Keras with Tesorflow as backend

Creating a gesture

  1. First set your hand histogram. You do not need to do it again if you have already done it. But you do need to do it if the lighting conditions change. To do so type the command given below and follow the instructions below.

python set_hand_hist.py
  • A windows "Set hand histogram" will appear.

  • "Set hand histogram" will have 50 squares (5x10).

  • Put your hand in those squares.

  • Press 'c'. 2 other windows will appear. "res" and "Thresh".

  • On pressing 'c' only the parts of the image which has your skin color should appear on the "res" window. White patches corresponding to this should appear on the "Thresh" window.

  • In case you are not successful then move your hand a little bit and press 'c' again. Repeat this until you get a good histogram.

  • After you get a good histogram press 's' to save the histogram. All the windows close.

  1. The next thing you need to do is create your gestures. That is done by the command given below. On starting executing this program, you will have to enter the gesture number and gesture name/text. Then an OpenCV window called "Capturing gestures" which will appear. In the webcam feed you will see a green window (inside which you will have to do your gesture) and a counter that counts the number of pictures stored.

python create_gestures.py    
  1. Press 'c' when you are ready with your gesture. Capturing gesture will begin after a few seconds. Move your hand a little bit here and there. You can pause capturing by pressing 'c' and resume it by pressing 'c'. Capturing resumes after a few secondAfter the counter reaches 1200 the window will close automatically.

  2. When you are done adding new gestures run the load_images.py file once. You do not need to run this file again until and unless you add a new gesture.

python load_images.py

Displaying all gestures

  1. To see all the gestures that are stored in 'gestures/' folder run this command

python display_all_gestures.py

Training a model

  1. So training can be done with Keras. To train using Keras then use the cnn_keras.py file.

python cnn_keras.py
  1. If you use Keras you will have the model in the root directory by the name cnn_keras2.h5.

You do not need to retrain your model every time. In case you added or removed a gesture then you need to retrain it.

Running the calculator

  1. Make sure you have already run the set_hand_hist.py file to set the histogram.

  2. Run the hand-calculator.py file using the command below

python3 hand-calculator.py
  1. This version uses numbers in American Sign Language.

  2. To confirm a digit make sure you keep the same gesture for 20 frames. On successful confirmation, the number will appear in the vertical center of the black part of the window.

  3. To confirm a number make a fist and keep in the green box for 25 frames. You will get used to the timing :P.

  4. You can have any number of digits for both first number and second number.

  5. Currently there are 10 operators.

  6. During operator selection, 1 means '+', 2 means '-', 3 means '*', 4 means '/', 5 means '%', 6 means '**', 7 means '>>' or right shift operator, 8 means '<<' or left shift operator, 9 means '&' or bitwise AND and 0 means '|' or bitwise OR.

Got a question?

If you have any questions that are bothering you please contact me on my facebook profile. Just do not ask me questions like where do I live, who do I work for etc. Also no questions like what does this line do. If you think a line is redundant or can be removed to make the program better then you can obviously ask me or make a pull request.


链接:

https://github.com/EvilPort2/Simple-OpenCV-Calculator


原文链接:

https://m.weibo.cn/1402400261/4213754809570163

“完整内容”请点击【阅读原文】
↓↓↓
登录查看更多
3

相关内容

《强化学习—使用 Open AI、TensorFlow和Keras实现》174页pdf
专知会员服务
136+阅读 · 2020年3月1日
【新书】Python数据科学食谱(Python Data Science Cookbook)
专知会员服务
113+阅读 · 2020年1月1日
Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
144+阅读 · 2019年10月12日
开源书:PyTorch深度学习起步
专知会员服务
49+阅读 · 2019年10月11日
强化学习最新教程,17页pdf
专知会员服务
167+阅读 · 2019年10月11日
[综述]深度学习下的场景文本检测与识别
专知会员服务
77+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
机器学习相关资源(框架、库、软件)大列表
专知会员服务
37+阅读 · 2019年10月9日
Opencv+TF-Slim实现图像分类及深度特征提取
极市平台
16+阅读 · 2019年8月19日
通过Docker安装谷歌足球游戏环境
CreateAMind
11+阅读 · 2019年7月7日
【推荐】(TensorFlow)SSD实时手部检测与追踪(附代码)
机器学习研究会
11+阅读 · 2017年12月5日
【推荐】用Python/OpenCV实现增强现实
机器学习研究会
14+阅读 · 2017年11月16日
Capsule Networks解析
机器学习研究会
10+阅读 · 2017年11月12日
【推荐】YOLO实时目标检测(6fps)
机器学习研究会
20+阅读 · 2017年11月5日
【推荐】树莓派/OpenCV/dlib人脸定位/瞌睡检测
机器学习研究会
9+阅读 · 2017年10月24日
【推荐】用Tensorflow理解LSTM
机器学习研究会
36+阅读 · 2017年9月11日
【推荐】(Keras)LSTM多元时序预测教程
机器学习研究会
24+阅读 · 2017年8月14日
Neural Image Captioning
Arxiv
5+阅读 · 2019年7月2日
Arxiv
8+阅读 · 2018年1月12日
VIP会员
相关VIP内容
《强化学习—使用 Open AI、TensorFlow和Keras实现》174页pdf
专知会员服务
136+阅读 · 2020年3月1日
【新书】Python数据科学食谱(Python Data Science Cookbook)
专知会员服务
113+阅读 · 2020年1月1日
Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
144+阅读 · 2019年10月12日
开源书:PyTorch深度学习起步
专知会员服务
49+阅读 · 2019年10月11日
强化学习最新教程,17页pdf
专知会员服务
167+阅读 · 2019年10月11日
[综述]深度学习下的场景文本检测与识别
专知会员服务
77+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
机器学习相关资源(框架、库、软件)大列表
专知会员服务
37+阅读 · 2019年10月9日
相关资讯
Opencv+TF-Slim实现图像分类及深度特征提取
极市平台
16+阅读 · 2019年8月19日
通过Docker安装谷歌足球游戏环境
CreateAMind
11+阅读 · 2019年7月7日
【推荐】(TensorFlow)SSD实时手部检测与追踪(附代码)
机器学习研究会
11+阅读 · 2017年12月5日
【推荐】用Python/OpenCV实现增强现实
机器学习研究会
14+阅读 · 2017年11月16日
Capsule Networks解析
机器学习研究会
10+阅读 · 2017年11月12日
【推荐】YOLO实时目标检测(6fps)
机器学习研究会
20+阅读 · 2017年11月5日
【推荐】树莓派/OpenCV/dlib人脸定位/瞌睡检测
机器学习研究会
9+阅读 · 2017年10月24日
【推荐】用Tensorflow理解LSTM
机器学习研究会
36+阅读 · 2017年9月11日
【推荐】(Keras)LSTM多元时序预测教程
机器学习研究会
24+阅读 · 2017年8月14日
Top
微信扫码咨询专知VIP会员