robovisionarm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robovisionarm-0.1.0/LICENSE +21 -0
- robovisionarm-0.1.0/PKG-INFO +235 -0
- robovisionarm-0.1.0/README.md +221 -0
- robovisionarm-0.1.0/examples/run_arm.py +9 -0
- robovisionarm-0.1.0/pyproject.toml +24 -0
- robovisionarm-0.1.0/robovisionarm/__init__.py +1 -0
- robovisionarm-0.1.0/robovisionarm/config.py +12 -0
- robovisionarm-0.1.0/robovisionarm/controller.py +104 -0
- robovisionarm-0.1.0/robovisionarm/gestures.py +39 -0
- robovisionarm-0.1.0/robovisionarm/serial_comm.py +35 -0
- robovisionarm-0.1.0/robovisionarm.egg-info/PKG-INFO +235 -0
- robovisionarm-0.1.0/robovisionarm.egg-info/SOURCES.txt +15 -0
- robovisionarm-0.1.0/robovisionarm.egg-info/dependency_links.txt +1 -0
- robovisionarm-0.1.0/robovisionarm.egg-info/requires.txt +3 -0
- robovisionarm-0.1.0/robovisionarm.egg-info/top_level.txt +3 -0
- robovisionarm-0.1.0/setup.cfg +4 -0
- robovisionarm-0.1.0/setup.py +7 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Naman Lohiya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: robovisionarm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Computer Vision Controlled DIY Robotic Arm
|
|
5
|
+
Author: Naman Lohiya
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: opencv-python
|
|
11
|
+
Requires-Dist: mediapipe
|
|
12
|
+
Requires-Dist: pyserial
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# ๐ค RoboVisionArm
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
**RoboVisionArm** is a Python library that enables **real-time control of a DIY robotic arm using computer vision and hand gestures**.
|
|
23
|
+
It uses **OpenCV**, **MediaPipe**, and **Arduino serial communication** to convert hand movements into robotic arm motion.
|
|
24
|
+
|
|
25
|
+
This library is ideal for:
|
|
26
|
+
|
|
27
|
+
* ๐ค DIY robotic arm projects
|
|
28
|
+
* ๐ Engineering and robotics students
|
|
29
|
+
* ๐งช Science exhibitions and competitions
|
|
30
|
+
* ๐ฌ Robotics and computer vision research
|
|
31
|
+
* ๐ญ Prototype automation systems
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# ๐ฅ Demo Video
|
|
36
|
+
|
|
37
|
+
Upload your demo video (`robotarm.mp4`) to your GitHub repository and embed it here.
|
|
38
|
+
|
|
39
|
+
Example:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
https://github.com/YOUR_USERNAME/robovisionarm/blob/main/robotarm.mp4
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
GitHub will automatically show a video player.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# ๐ฆ Installation
|
|
50
|
+
|
|
51
|
+
Install from PyPI:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
pip install robovisionarm
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or install dependencies manually:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
pip install opencv-python mediapipe pyserial
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# โก Quick Start
|
|
66
|
+
|
|
67
|
+
This is the fastest way to run your robotic arm:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from robovisionarm import RoboVisionArm
|
|
71
|
+
|
|
72
|
+
arm = RoboVisionArm(
|
|
73
|
+
port="COM3", # Change to your Arduino port (example: COM3 or /dev/ttyUSB0)
|
|
74
|
+
camera_index=0, # Default webcam
|
|
75
|
+
debug=False # True = print angles only
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
arm.run()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Press **ESC** to safely exit.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
# ๐ฎ Gesture Controls
|
|
86
|
+
|
|
87
|
+
| Gesture | Robotic Arm Movement |
|
|
88
|
+
| ----------------------------- | ----------------------- |
|
|
89
|
+
| Move hand LEFT / RIGHT | Base rotation |
|
|
90
|
+
| Move hand UP / DOWN | Shoulder movement |
|
|
91
|
+
| Move hand forward / backward | Elbow movement |
|
|
92
|
+
| Extend index & middle fingers | Wrist rotation |
|
|
93
|
+
| Pinch thumb and index finger | Open / Close gripper |
|
|
94
|
+
| No hand detected | Return to home position |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
# ๐ Arduino Setup
|
|
99
|
+
|
|
100
|
+
Upload this code to your Arduino:
|
|
101
|
+
|
|
102
|
+
```cpp
|
|
103
|
+
#include <Servo.h>
|
|
104
|
+
|
|
105
|
+
Servo base;
|
|
106
|
+
Servo shoulder;
|
|
107
|
+
Servo elbow;
|
|
108
|
+
Servo wrist;
|
|
109
|
+
Servo gripper;
|
|
110
|
+
|
|
111
|
+
void setup()
|
|
112
|
+
{
|
|
113
|
+
Serial.begin(115200);
|
|
114
|
+
|
|
115
|
+
base.attach(3);
|
|
116
|
+
shoulder.attach(5);
|
|
117
|
+
elbow.attach(6);
|
|
118
|
+
wrist.attach(9);
|
|
119
|
+
gripper.attach(10);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void loop()
|
|
123
|
+
{
|
|
124
|
+
if (Serial.available() >= 5)
|
|
125
|
+
{
|
|
126
|
+
base.write(Serial.read());
|
|
127
|
+
shoulder.write(Serial.read());
|
|
128
|
+
elbow.write(Serial.read());
|
|
129
|
+
wrist.write(Serial.read());
|
|
130
|
+
gripper.write(Serial.read());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
# ๐ง How It Works
|
|
138
|
+
|
|
139
|
+
1. Webcam captures live video
|
|
140
|
+
2. MediaPipe detects hand landmarks
|
|
141
|
+
3. Landmarks convert into servo angles
|
|
142
|
+
4. Python sends angles via serial communication
|
|
143
|
+
5. Arduino moves servo motors
|
|
144
|
+
|
|
145
|
+
All of this happens in **real time**.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
# ๐ Example Usage
|
|
150
|
+
|
|
151
|
+
Run example script:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
python examples/run_arm.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
# โ๏ธ Library Parameters
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
RoboVisionArm(
|
|
163
|
+
port="COM3",
|
|
164
|
+
camera_index=0,
|
|
165
|
+
debug=False
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| Parameter | Description |
|
|
170
|
+
| ------------ | ------------------------------- |
|
|
171
|
+
| port | Arduino serial port |
|
|
172
|
+
| camera_index | Webcam index |
|
|
173
|
+
| debug | Print angles instead of sending |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
# ๐ฆพ Hardware Requirements
|
|
178
|
+
|
|
179
|
+
* Arduino Uno / Nano / Mega
|
|
180
|
+
* Servo motors (SG90, MG996R, etc.)
|
|
181
|
+
* USB Webcam
|
|
182
|
+
* DIY robotic arm
|
|
183
|
+
* External power supply (recommended)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
# ๐ Applications
|
|
188
|
+
|
|
189
|
+
* Gesture-controlled robotic arms
|
|
190
|
+
* Industrial robotic prototypes
|
|
191
|
+
* Educational robotics labs
|
|
192
|
+
* Computer vision research
|
|
193
|
+
* Automation demonstrations
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# ๐ Project Structure
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
robovisionarm/
|
|
201
|
+
โ
|
|
202
|
+
โโโ robovisionarm/
|
|
203
|
+
โ โโโ controller.py
|
|
204
|
+
โ โโโ gestures.py
|
|
205
|
+
โ โโโ serial_comm.py
|
|
206
|
+
โ โโโ config.py
|
|
207
|
+
โ
|
|
208
|
+
โโโ examples/
|
|
209
|
+
โ โโโ run_arm.py
|
|
210
|
+
โ
|
|
211
|
+
โโโ README.md
|
|
212
|
+
โโโ LICENSE
|
|
213
|
+
โโโ pyproject.toml
|
|
214
|
+
โโโ setup.py
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# ๐งโ๐ป Author
|
|
220
|
+
|
|
221
|
+
**Naman Lohiya**
|
|
222
|
+
Robotics and Computer Vision Developer
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
# ๐ License
|
|
227
|
+
|
|
228
|
+
MIT License
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
# โญ Support
|
|
233
|
+
|
|
234
|
+
If you like this project, consider starring the GitHub repository and sharing it with the robotics community.
|
|
235
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# ๐ค RoboVisionArm
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
**RoboVisionArm** is a Python library that enables **real-time control of a DIY robotic arm using computer vision and hand gestures**.
|
|
9
|
+
It uses **OpenCV**, **MediaPipe**, and **Arduino serial communication** to convert hand movements into robotic arm motion.
|
|
10
|
+
|
|
11
|
+
This library is ideal for:
|
|
12
|
+
|
|
13
|
+
* ๐ค DIY robotic arm projects
|
|
14
|
+
* ๐ Engineering and robotics students
|
|
15
|
+
* ๐งช Science exhibitions and competitions
|
|
16
|
+
* ๐ฌ Robotics and computer vision research
|
|
17
|
+
* ๐ญ Prototype automation systems
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# ๐ฅ Demo Video
|
|
22
|
+
|
|
23
|
+
Upload your demo video (`robotarm.mp4`) to your GitHub repository and embed it here.
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
https://github.com/YOUR_USERNAME/robovisionarm/blob/main/robotarm.mp4
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
GitHub will automatically show a video player.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# ๐ฆ Installation
|
|
36
|
+
|
|
37
|
+
Install from PyPI:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install robovisionarm
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or install dependencies manually:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
pip install opencv-python mediapipe pyserial
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
# โก Quick Start
|
|
52
|
+
|
|
53
|
+
This is the fastest way to run your robotic arm:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from robovisionarm import RoboVisionArm
|
|
57
|
+
|
|
58
|
+
arm = RoboVisionArm(
|
|
59
|
+
port="COM3", # Change to your Arduino port (example: COM3 or /dev/ttyUSB0)
|
|
60
|
+
camera_index=0, # Default webcam
|
|
61
|
+
debug=False # True = print angles only
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
arm.run()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Press **ESC** to safely exit.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
# ๐ฎ Gesture Controls
|
|
72
|
+
|
|
73
|
+
| Gesture | Robotic Arm Movement |
|
|
74
|
+
| ----------------------------- | ----------------------- |
|
|
75
|
+
| Move hand LEFT / RIGHT | Base rotation |
|
|
76
|
+
| Move hand UP / DOWN | Shoulder movement |
|
|
77
|
+
| Move hand forward / backward | Elbow movement |
|
|
78
|
+
| Extend index & middle fingers | Wrist rotation |
|
|
79
|
+
| Pinch thumb and index finger | Open / Close gripper |
|
|
80
|
+
| No hand detected | Return to home position |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
# ๐ Arduino Setup
|
|
85
|
+
|
|
86
|
+
Upload this code to your Arduino:
|
|
87
|
+
|
|
88
|
+
```cpp
|
|
89
|
+
#include <Servo.h>
|
|
90
|
+
|
|
91
|
+
Servo base;
|
|
92
|
+
Servo shoulder;
|
|
93
|
+
Servo elbow;
|
|
94
|
+
Servo wrist;
|
|
95
|
+
Servo gripper;
|
|
96
|
+
|
|
97
|
+
void setup()
|
|
98
|
+
{
|
|
99
|
+
Serial.begin(115200);
|
|
100
|
+
|
|
101
|
+
base.attach(3);
|
|
102
|
+
shoulder.attach(5);
|
|
103
|
+
elbow.attach(6);
|
|
104
|
+
wrist.attach(9);
|
|
105
|
+
gripper.attach(10);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void loop()
|
|
109
|
+
{
|
|
110
|
+
if (Serial.available() >= 5)
|
|
111
|
+
{
|
|
112
|
+
base.write(Serial.read());
|
|
113
|
+
shoulder.write(Serial.read());
|
|
114
|
+
elbow.write(Serial.read());
|
|
115
|
+
wrist.write(Serial.read());
|
|
116
|
+
gripper.write(Serial.read());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
# ๐ง How It Works
|
|
124
|
+
|
|
125
|
+
1. Webcam captures live video
|
|
126
|
+
2. MediaPipe detects hand landmarks
|
|
127
|
+
3. Landmarks convert into servo angles
|
|
128
|
+
4. Python sends angles via serial communication
|
|
129
|
+
5. Arduino moves servo motors
|
|
130
|
+
|
|
131
|
+
All of this happens in **real time**.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
# ๐ Example Usage
|
|
136
|
+
|
|
137
|
+
Run example script:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
python examples/run_arm.py
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
# โ๏ธ Library Parameters
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
RoboVisionArm(
|
|
149
|
+
port="COM3",
|
|
150
|
+
camera_index=0,
|
|
151
|
+
debug=False
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| Parameter | Description |
|
|
156
|
+
| ------------ | ------------------------------- |
|
|
157
|
+
| port | Arduino serial port |
|
|
158
|
+
| camera_index | Webcam index |
|
|
159
|
+
| debug | Print angles instead of sending |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
# ๐ฆพ Hardware Requirements
|
|
164
|
+
|
|
165
|
+
* Arduino Uno / Nano / Mega
|
|
166
|
+
* Servo motors (SG90, MG996R, etc.)
|
|
167
|
+
* USB Webcam
|
|
168
|
+
* DIY robotic arm
|
|
169
|
+
* External power supply (recommended)
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
# ๐ Applications
|
|
174
|
+
|
|
175
|
+
* Gesture-controlled robotic arms
|
|
176
|
+
* Industrial robotic prototypes
|
|
177
|
+
* Educational robotics labs
|
|
178
|
+
* Computer vision research
|
|
179
|
+
* Automation demonstrations
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
# ๐ Project Structure
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
robovisionarm/
|
|
187
|
+
โ
|
|
188
|
+
โโโ robovisionarm/
|
|
189
|
+
โ โโโ controller.py
|
|
190
|
+
โ โโโ gestures.py
|
|
191
|
+
โ โโโ serial_comm.py
|
|
192
|
+
โ โโโ config.py
|
|
193
|
+
โ
|
|
194
|
+
โโโ examples/
|
|
195
|
+
โ โโโ run_arm.py
|
|
196
|
+
โ
|
|
197
|
+
โโโ README.md
|
|
198
|
+
โโโ LICENSE
|
|
199
|
+
โโโ pyproject.toml
|
|
200
|
+
โโโ setup.py
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
# ๐งโ๐ป Author
|
|
206
|
+
|
|
207
|
+
**Naman Lohiya**
|
|
208
|
+
Robotics and Computer Vision Developer
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
# ๐ License
|
|
213
|
+
|
|
214
|
+
MIT License
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
# โญ Support
|
|
219
|
+
|
|
220
|
+
If you like this project, consider starring the GitHub repository and sharing it with the robotics community.
|
|
221
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "robovisionarm"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Computer Vision Controlled DIY Robotic Arm"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Naman Lohiya" }
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
license = "MIT"
|
|
16
|
+
|
|
17
|
+
dependencies = [
|
|
18
|
+
"opencv-python",
|
|
19
|
+
"mediapipe",
|
|
20
|
+
"pyserial"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["."]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .controller import RoboVisionArm
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import cv2
|
|
2
|
+
import mediapipe as mp
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
from .serial_comm import ArduinoController
|
|
6
|
+
from .config import HOME_POSITION
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RoboVisionArm:
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
|
|
13
|
+
self,
|
|
14
|
+
port="COM3",
|
|
15
|
+
camera_index=0,
|
|
16
|
+
debug=False
|
|
17
|
+
):
|
|
18
|
+
|
|
19
|
+
self.arduino = ArduinoController(port, debug=debug)
|
|
20
|
+
|
|
21
|
+
self.cap = cv2.VideoCapture(camera_index)
|
|
22
|
+
|
|
23
|
+
self.current_angles = HOME_POSITION.copy()
|
|
24
|
+
|
|
25
|
+
self.mp_hands = mp.solutions.hands.Hands(
|
|
26
|
+
min_detection_confidence=0.5,
|
|
27
|
+
min_tracking_confidence=0.5
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def compute_angles(self, hand):
|
|
32
|
+
|
|
33
|
+
wrist = hand.landmark[0]
|
|
34
|
+
|
|
35
|
+
base = int(wrist.x * 180)
|
|
36
|
+
|
|
37
|
+
shoulder = int(wrist.y * 180)
|
|
38
|
+
|
|
39
|
+
elbow = 90
|
|
40
|
+
|
|
41
|
+
wrist_rot = 60
|
|
42
|
+
|
|
43
|
+
gripper = 90
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
|
|
47
|
+
base,
|
|
48
|
+
shoulder,
|
|
49
|
+
elbow,
|
|
50
|
+
wrist_rot,
|
|
51
|
+
gripper
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def step(self):
|
|
56
|
+
|
|
57
|
+
success, frame = self.cap.read()
|
|
58
|
+
|
|
59
|
+
if not success:
|
|
60
|
+
return True
|
|
61
|
+
|
|
62
|
+
rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
|
63
|
+
|
|
64
|
+
results = self.mp_hands.process(rgb)
|
|
65
|
+
|
|
66
|
+
if results.multi_hand_landmarks:
|
|
67
|
+
|
|
68
|
+
hand = results.multi_hand_landmarks[0]
|
|
69
|
+
|
|
70
|
+
angles = self.compute_angles(hand)
|
|
71
|
+
|
|
72
|
+
self.current_angles = angles
|
|
73
|
+
|
|
74
|
+
self.arduino.send_angles(angles)
|
|
75
|
+
|
|
76
|
+
cv2.imshow("RoboVisionArm", frame)
|
|
77
|
+
|
|
78
|
+
if cv2.waitKey(1) == 27:
|
|
79
|
+
return False
|
|
80
|
+
|
|
81
|
+
return True
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def run(self):
|
|
85
|
+
|
|
86
|
+
print("Starting RoboVisionArm...")
|
|
87
|
+
|
|
88
|
+
while True:
|
|
89
|
+
|
|
90
|
+
if not self.step():
|
|
91
|
+
break
|
|
92
|
+
|
|
93
|
+
self.shutdown()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def shutdown(self):
|
|
97
|
+
|
|
98
|
+
print("Shutting down")
|
|
99
|
+
|
|
100
|
+
self.cap.release()
|
|
101
|
+
|
|
102
|
+
self.arduino.close()
|
|
103
|
+
|
|
104
|
+
cv2.destroyAllWindows()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
def clamp(x, min_val, max_val):
|
|
4
|
+
|
|
5
|
+
return max(min_val, min(x, max_val))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def map_range(x, in_min, in_max, out_min, out_max):
|
|
9
|
+
|
|
10
|
+
return int(
|
|
11
|
+
(x - in_min)
|
|
12
|
+
* (out_max - out_min)
|
|
13
|
+
/ (in_max - in_min)
|
|
14
|
+
+ out_min
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def palm_size(hand):
|
|
19
|
+
|
|
20
|
+
wrist = hand.landmark[0]
|
|
21
|
+
index = hand.landmark[5]
|
|
22
|
+
|
|
23
|
+
return math.sqrt(
|
|
24
|
+
(wrist.x-index.x)**2 +
|
|
25
|
+
(wrist.y-index.y)**2 +
|
|
26
|
+
(wrist.z-index.z)**2
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def pinch_distance(hand):
|
|
31
|
+
|
|
32
|
+
thumb = hand.landmark[4]
|
|
33
|
+
index = hand.landmark[8]
|
|
34
|
+
|
|
35
|
+
return math.sqrt(
|
|
36
|
+
(thumb.x-index.x)**2 +
|
|
37
|
+
(thumb.y-index.y)**2 +
|
|
38
|
+
(thumb.z-index.z)**2
|
|
39
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import serial
|
|
2
|
+
|
|
3
|
+
class ArduinoController:
|
|
4
|
+
|
|
5
|
+
def __init__(self, port="COM3", baudrate=115200, debug=False):
|
|
6
|
+
|
|
7
|
+
self.debug = debug
|
|
8
|
+
self.ser = None
|
|
9
|
+
|
|
10
|
+
if not debug:
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
self.ser = serial.Serial(port, baudrate, timeout=1)
|
|
14
|
+
print(f"Connected to Arduino on {port}")
|
|
15
|
+
|
|
16
|
+
except Exception as e:
|
|
17
|
+
|
|
18
|
+
print("Serial failed โ Debug mode:", e)
|
|
19
|
+
self.debug = True
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def send_angles(self, angles):
|
|
23
|
+
|
|
24
|
+
if self.debug:
|
|
25
|
+
|
|
26
|
+
print("DEBUG ANGLES:", angles)
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
self.ser.write(bytearray([int(a) for a in angles]))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def close(self):
|
|
33
|
+
|
|
34
|
+
if self.ser:
|
|
35
|
+
self.ser.close()
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: robovisionarm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Computer Vision Controlled DIY Robotic Arm
|
|
5
|
+
Author: Naman Lohiya
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: opencv-python
|
|
11
|
+
Requires-Dist: mediapipe
|
|
12
|
+
Requires-Dist: pyserial
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# ๐ค RoboVisionArm
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
**RoboVisionArm** is a Python library that enables **real-time control of a DIY robotic arm using computer vision and hand gestures**.
|
|
23
|
+
It uses **OpenCV**, **MediaPipe**, and **Arduino serial communication** to convert hand movements into robotic arm motion.
|
|
24
|
+
|
|
25
|
+
This library is ideal for:
|
|
26
|
+
|
|
27
|
+
* ๐ค DIY robotic arm projects
|
|
28
|
+
* ๐ Engineering and robotics students
|
|
29
|
+
* ๐งช Science exhibitions and competitions
|
|
30
|
+
* ๐ฌ Robotics and computer vision research
|
|
31
|
+
* ๐ญ Prototype automation systems
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# ๐ฅ Demo Video
|
|
36
|
+
|
|
37
|
+
Upload your demo video (`robotarm.mp4`) to your GitHub repository and embed it here.
|
|
38
|
+
|
|
39
|
+
Example:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
https://github.com/YOUR_USERNAME/robovisionarm/blob/main/robotarm.mp4
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
GitHub will automatically show a video player.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# ๐ฆ Installation
|
|
50
|
+
|
|
51
|
+
Install from PyPI:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
pip install robovisionarm
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or install dependencies manually:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
pip install opencv-python mediapipe pyserial
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# โก Quick Start
|
|
66
|
+
|
|
67
|
+
This is the fastest way to run your robotic arm:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from robovisionarm import RoboVisionArm
|
|
71
|
+
|
|
72
|
+
arm = RoboVisionArm(
|
|
73
|
+
port="COM3", # Change to your Arduino port (example: COM3 or /dev/ttyUSB0)
|
|
74
|
+
camera_index=0, # Default webcam
|
|
75
|
+
debug=False # True = print angles only
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
arm.run()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Press **ESC** to safely exit.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
# ๐ฎ Gesture Controls
|
|
86
|
+
|
|
87
|
+
| Gesture | Robotic Arm Movement |
|
|
88
|
+
| ----------------------------- | ----------------------- |
|
|
89
|
+
| Move hand LEFT / RIGHT | Base rotation |
|
|
90
|
+
| Move hand UP / DOWN | Shoulder movement |
|
|
91
|
+
| Move hand forward / backward | Elbow movement |
|
|
92
|
+
| Extend index & middle fingers | Wrist rotation |
|
|
93
|
+
| Pinch thumb and index finger | Open / Close gripper |
|
|
94
|
+
| No hand detected | Return to home position |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
# ๐ Arduino Setup
|
|
99
|
+
|
|
100
|
+
Upload this code to your Arduino:
|
|
101
|
+
|
|
102
|
+
```cpp
|
|
103
|
+
#include <Servo.h>
|
|
104
|
+
|
|
105
|
+
Servo base;
|
|
106
|
+
Servo shoulder;
|
|
107
|
+
Servo elbow;
|
|
108
|
+
Servo wrist;
|
|
109
|
+
Servo gripper;
|
|
110
|
+
|
|
111
|
+
void setup()
|
|
112
|
+
{
|
|
113
|
+
Serial.begin(115200);
|
|
114
|
+
|
|
115
|
+
base.attach(3);
|
|
116
|
+
shoulder.attach(5);
|
|
117
|
+
elbow.attach(6);
|
|
118
|
+
wrist.attach(9);
|
|
119
|
+
gripper.attach(10);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void loop()
|
|
123
|
+
{
|
|
124
|
+
if (Serial.available() >= 5)
|
|
125
|
+
{
|
|
126
|
+
base.write(Serial.read());
|
|
127
|
+
shoulder.write(Serial.read());
|
|
128
|
+
elbow.write(Serial.read());
|
|
129
|
+
wrist.write(Serial.read());
|
|
130
|
+
gripper.write(Serial.read());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
# ๐ง How It Works
|
|
138
|
+
|
|
139
|
+
1. Webcam captures live video
|
|
140
|
+
2. MediaPipe detects hand landmarks
|
|
141
|
+
3. Landmarks convert into servo angles
|
|
142
|
+
4. Python sends angles via serial communication
|
|
143
|
+
5. Arduino moves servo motors
|
|
144
|
+
|
|
145
|
+
All of this happens in **real time**.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
# ๐ Example Usage
|
|
150
|
+
|
|
151
|
+
Run example script:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
python examples/run_arm.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
# โ๏ธ Library Parameters
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
RoboVisionArm(
|
|
163
|
+
port="COM3",
|
|
164
|
+
camera_index=0,
|
|
165
|
+
debug=False
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| Parameter | Description |
|
|
170
|
+
| ------------ | ------------------------------- |
|
|
171
|
+
| port | Arduino serial port |
|
|
172
|
+
| camera_index | Webcam index |
|
|
173
|
+
| debug | Print angles instead of sending |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
# ๐ฆพ Hardware Requirements
|
|
178
|
+
|
|
179
|
+
* Arduino Uno / Nano / Mega
|
|
180
|
+
* Servo motors (SG90, MG996R, etc.)
|
|
181
|
+
* USB Webcam
|
|
182
|
+
* DIY robotic arm
|
|
183
|
+
* External power supply (recommended)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
# ๐ Applications
|
|
188
|
+
|
|
189
|
+
* Gesture-controlled robotic arms
|
|
190
|
+
* Industrial robotic prototypes
|
|
191
|
+
* Educational robotics labs
|
|
192
|
+
* Computer vision research
|
|
193
|
+
* Automation demonstrations
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# ๐ Project Structure
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
robovisionarm/
|
|
201
|
+
โ
|
|
202
|
+
โโโ robovisionarm/
|
|
203
|
+
โ โโโ controller.py
|
|
204
|
+
โ โโโ gestures.py
|
|
205
|
+
โ โโโ serial_comm.py
|
|
206
|
+
โ โโโ config.py
|
|
207
|
+
โ
|
|
208
|
+
โโโ examples/
|
|
209
|
+
โ โโโ run_arm.py
|
|
210
|
+
โ
|
|
211
|
+
โโโ README.md
|
|
212
|
+
โโโ LICENSE
|
|
213
|
+
โโโ pyproject.toml
|
|
214
|
+
โโโ setup.py
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# ๐งโ๐ป Author
|
|
220
|
+
|
|
221
|
+
**Naman Lohiya**
|
|
222
|
+
Robotics and Computer Vision Developer
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
# ๐ License
|
|
227
|
+
|
|
228
|
+
MIT License
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
# โญ Support
|
|
233
|
+
|
|
234
|
+
If you like this project, consider starring the GitHub repository and sharing it with the robotics community.
|
|
235
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
examples/run_arm.py
|
|
6
|
+
robovisionarm/__init__.py
|
|
7
|
+
robovisionarm/config.py
|
|
8
|
+
robovisionarm/controller.py
|
|
9
|
+
robovisionarm/gestures.py
|
|
10
|
+
robovisionarm/serial_comm.py
|
|
11
|
+
robovisionarm.egg-info/PKG-INFO
|
|
12
|
+
robovisionarm.egg-info/SOURCES.txt
|
|
13
|
+
robovisionarm.egg-info/dependency_links.txt
|
|
14
|
+
robovisionarm.egg-info/requires.txt
|
|
15
|
+
robovisionarm.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|