(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

相关内容

Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
163+阅读 · 2019年10月12日
开源书:PyTorch深度学习起步
专知会员服务
51+阅读 · 2019年10月11日
强化学习最新教程,17页pdf
专知会员服务
182+阅读 · 2019年10月11日
[综述]深度学习下的场景文本检测与识别
专知会员服务
78+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
【推荐】(TensorFlow)SSD实时手部检测与追踪(附代码)
机器学习研究会
11+阅读 · 2017年12月5日
【推荐】用Python/OpenCV实现增强现实
机器学习研究会
15+阅读 · 2017年11月16日
【推荐】树莓派/OpenCV/dlib人脸定位/瞌睡检测
机器学习研究会
9+阅读 · 2017年10月24日
【推荐】用Tensorflow理解LSTM
机器学习研究会
36+阅读 · 2017年9月11日
【推荐】(Keras)LSTM多元时序预测教程
机器学习研究会
24+阅读 · 2017年8月14日
VIP会员
相关VIP内容
Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
163+阅读 · 2019年10月12日
开源书:PyTorch深度学习起步
专知会员服务
51+阅读 · 2019年10月11日
强化学习最新教程,17页pdf
专知会员服务
182+阅读 · 2019年10月11日
[综述]深度学习下的场景文本检测与识别
专知会员服务
78+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
相关资讯
【推荐】(TensorFlow)SSD实时手部检测与追踪(附代码)
机器学习研究会
11+阅读 · 2017年12月5日
【推荐】用Python/OpenCV实现增强现实
机器学习研究会
15+阅读 · 2017年11月16日
【推荐】树莓派/OpenCV/dlib人脸定位/瞌睡检测
机器学习研究会
9+阅读 · 2017年10月24日
【推荐】用Tensorflow理解LSTM
机器学习研究会
36+阅读 · 2017年9月11日
【推荐】(Keras)LSTM多元时序预测教程
机器学习研究会
24+阅读 · 2017年8月14日
Top
微信扫码咨询专知VIP会员