Following your hand
It is essential to be able to see if you want to follow your hand. Fortunately, adding hardware and software for vision is both easy and inexpensive. As you learned in Chapter 2, Building Your Own Futuristic Robot, connecting a USB camera is very easy.
Most importantly, OpenCV and your webcam can track your hand position. OpenCV makes this amazingly simple by providing some high-level libraries that can help us with this task. First, follow the instructions in Chapter 2, Building Your Own Futuristic Robot, to install your USB webcam and OpenCV.
Then you'll create a set of code that looks like this:
#!/usr/bin/python import cv2 import numpy as np import math cap = cv2.VideoCapture(0) cap.set(3, 360) cap.set(4, 240) while(cap.isOpened()): ...
Get Raspberry Pi Robotic Projects - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.