The Real-Time Hand Detection OpenCV Python was developed using Python Detection OpenCV, Hand detection is a simple idea, but it requires some advanced tools to do it. This project is one of the system that can detect the gesture of hand in a real time video.
A Hand Detection OpenCV Python is one of the most viable and popular solution for improving human computer interaction. The code is consist of a single file and can be executed from the command line or terminal by calling: “py main.py“.
|Project Name:||Hand Detection OpenCV Python With Source Code|
|Language/s Used:||Python (OpenCV)|
|Python version (Recommended):||2.x or 3.x|
|Type:||Deep Learning Project|
About Hand Detection OpenCV Python
In this OpenCV Python Project also includes a downloadable Python Project With Source Code for free, just find the downloadable source code below and click to start downloading.
When running the python file, you can expect to see the real time frame from your camera with a bounding rectangular framing your hand.
By the way if you are new to python programming and you don’t know what would be the the Python IDE to use, I have here a list of Best Python IDE for Windows, Linux, Mac OS that will suit for you. I also have here How to Download and Install Latest Version of Python on Windows.
To start executing a Real-Time Hand Detection With Source Code, make sure that you have installed Python in your computer.
Steps On How To Run Hand Detection OpenCV Python With Source Code
Time needed: 5 minutes.
These are the steps on how to run Real-Time Hand Detection OpenCV Python With Source Code
- Step 1: Download the given source code below.
First, download the given source code below and unzip the source code.
- Step 2: Import the project to your PyCharm IDE.
Next, import the source code you’ve download to your PyCharm IDE.
- Step 3: Run the project.
last, run the project with the command “py main.py”
Complete Source Code
import cv2 # Load the cascade face_cascade = cv2.CascadeClassifier('haarcascade_hand.xml') # To capture video from webcam. cap = cv2.VideoCapture(0) # To use a video file as input # cap = cv2.VideoCapture('filename.mp4') while True: # Read the frame _, img = cap.read() # Convert to grayscale gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Detect the faces faces = face_cascade.detectMultiScale(gray, 1.1, 4) # Draw the rectangle around each face for (x, y, w, h) in faces: cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2) # Display cv2.imshow('img', img) # Stop if escape key is pressed k = cv2.waitKey(30) & 0xff if k==27: break # Release the VideoCapture object cap.release()
Download Source Code below
In this tutorial you will learn about detecting a Hand with the feature mappers knows as haar cascades. Here in the project, we will use the python language along with the OpenCV library for the algorithm execution and image processing respectively.
The haar cascades we are going to use in the project are pretrained and stored along with the OpenCV library as haarcascade_hand.xml files.
The project develops a basic understanding of the systems such as hand detection and also the haar cascades usage with the OpenCV library.
If you have any questions or suggestions about Real-Time Hand Detection OpenCV Python With Source Code, please feel free to leave a comment below.