Raspberry Pi Measures Distance with a Webcam and Open CV

Raspberry Pi
(Image credit: Freedom Tech)

Distance sensors are an excellent tool for a variety of Raspberry Pi projects ranging from things like robotic navigation to this automatic soap dispenser. But what if you aren’t able to get ahold of one? Thankfully, the Pi community is incredibly robust. The makers at Freedom Tech have developed a workaround solution that uses a webcam with OpenCV to calculate the distance of a given user's hand from the camera.

This project relies heavily on OpenCV and uses our favorite SBC—the Raspberry Pi. With the help of a webcam, the Pi is able to check images for whether or not a user's hand is visible. If it is, the Pi then determines the size of the hand and estimates the distance of said hand from the camera module before displaying the estimation through a video overlay.

Latest Videos FromTom's Hardware
Ash Hill
Contributing Writer

Ash Hill is a contributing writer for Tom's Hardware with a wealth of experience in the hobby electronics, 3D printing and PCs. She manages the Pi projects of the month and much of our daily Raspberry Pi reporting while also finding the best coupons and deals on all tech.