Book Image

Python Robotics Projects

By : Prof. Diwakar Vaish
Book Image

Python Robotics Projects

By: Prof. Diwakar Vaish

Overview of this book

Robotics is a fast-growing industry. Multiple surveys state that investment in the field has increased tenfold in the last 6 years, and is set to become a $100-billion sector by 2020. Robots are prevalent throughout all industries, and they are all set to be a part of our domestic lives. This book starts with the installation and basic steps in configuring a robotic controller. You'll then move on to setting up your environment to use Python with the robotic controller. You'll dive deep into building simple robotic projects, such as a pet-feeding robot, and more complicated projects, such as machine learning enabled home automation system (Jarvis), vision processing based robots and a self-driven robotic vehicle using Python. By the end of this book, you'll know how to build smart robots using Python.
Table of Contents (24 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Knowing the face


All right, we have detected the face by using a few lines of code, but I would not consider it to be a very big victory as we were fighting using the sword made by other developers. The learning set imported was a generic face learned set. However, in this chapter, we will go ahead and make our very own learning set to recognize a specific human face. This is really a cool thing and I'm sure you will love doing it.

So, let's get started. As you did earlier, go through the explanation first and then write the code so that you understand it very well.

Firstly, we are using the program to capture the images of the object that needs to be detected. In our case, this object will be a person and his face. So, let's see what we need to do:

import cv2
import numpy as np

faceDetect = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cam = cv2.VideoCapture(0)

sampleNum = 0

id = raw_input('enter user id')

while True:
        ret,img = cam.read()
        gray = cv2.cvtColor...