Spending a lot of time in front of the phone, especially when seated, has many negative effects - one of them is obesity. So mankind needs a device that will solve this problem! Using ESP32-CAM, Arduino and Python I created a prototype of such a device.
I started by typing "ESP32-CAM projects" on YouTube to look for similar projects and materials that I could use. A few of them proved to be useful, but none of them fully reflected what I meant. What exactly did I mean?
Step 2: DEVICE DETAILSMy goal was to be able to play a mobile game and control the character in a given game with my body movements. I planned to do it in such a way that I would run a mobile game on a laptop to which I would send the image from ESP32-CAM via WIFI. The image will be processed by a simple Python program that detects the face and transforms its position into appropriate movements. Let's start with electronics.
Step 3: ELECTRONICS1. Click on ARDUINO > PREFERENCES and paste the links in the film's description and click OK.
https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
2. Click Tools > Board > Board Manager > Enter "esp32" > Select Version 2.0.2 > Install
3. Open the program "esp32_cam_tut.ino".
4. Enter the name of your wifi network in the SSID field and the password to this network in the PASS field.
5. Click what I showed on the screen
Tools > Board > ESP32 Arduino > ESP32 Wrover Module
Upload Speed > 115200
Flash Sequence > 40MHz
Flash Mode > QIO
Partition Scheme > Huge APP
Core Debug Level > None
Port > Select your Device
6. Connect the circuit according to the schematic.
7. Click "Upload" and wait for the program to load, it may take about a minute.
8. Disconnect the DO1 pin from GND.
9. Open the serial port monitor by clicking on the magnifying glass icon in the upper right corner.
10. After clicking the reset button on the ESP32-CAM, a message will appear in the monitor of the serial port from which the IP address should be copied.
11. Open the program "esp32_famegame.py" and paste your IP address into it. After starting the program, the "live transmission" window will appear in which the image from the ESP camera will appear. If it detects a face, a red rectangle will be around the face.
Step 4: CONFIGURATIONI prepared two games that can be played with ESP32-CAM - Fame Game and Subway Surfers. However, before the programs will work properly, the configuration must be carried out, I will show it on the example of the Fame Game game:
1. Open the game on your computer.
2. Open the esp32_famegame.py program
3. Open the program "Pytest.py" and run this program. In the terminal it will display the current position of the mouse on the screen. Move to the place you want the mouse to click and save the cursor position first in one place and then in another.
4. Paste the cursor position into the program.
Now the webcam:
The image from the webcam has a resolution of 320x240, so it can be divided as on the photo. Depending on the position of the face, a different movement will be made - for example - the face will be on the left side, so the mouse will click on the left glove. Following the same scheme, I created a program for Subway Surfers.
Step 5: Final EffectMy Youtube: YouTube
My Facebook: Facebook
My Instagram: Instagram
$0 for 1-4 layers PCBs: NEXTPCB
Comments