Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Beaglebone Robotics

You're reading from   Mastering Beaglebone Robotics Master the power of the BeagleBone Black to maximize your robot-building skills and create awesome projects

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781783988907
Length 234 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Richard Grimmett Richard Grimmett
Author Profile Icon Richard Grimmett
Richard Grimmett
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Preparing the BeagleBone Black FREE CHAPTER 2. Building a Basic Tracked Vehicle 3. Adding Sensors to Your Tracked Vehicle 4. Vision and Image Processing 5. Building a Robot that Can Walk 6. A Robot that Can Sail 7. Using GPS for Navigation 8. Measuring Wind Speed – Integrating Analog Sensors 9. An Underwater Remotely Operated Vehicle 10. A Quadcopter 11. An Autonomous Quadcopter Index

Finding colored objects in your vision system

OpenCV can be used to track objects. As an example, let's build a system that tracks and follows a colored ball. OpenCV makes this activity amazingly simple; here are the steps:

  1. Create a directory to hold your image-based work. Once you have created the directory, go there and begin with your camera.py file.
  2. Now edit the file until it looks similar to the following screenshot:
    Finding colored objects in your vision system

    Let's look specifically at the changes you need to make to camera.py. The first three lines you add are as follows:

    cv.Smooth(img,img,cv.CV_BLUR,3)
    hue_img = cv.CreateImage(cv.GetSize(img), 8, 3)
    cv.CvtColor(img,hue_img, cv.CV_BGR2HSV)
    

    We are going to use the OpenCV library to first smooth the image, taking out any large deviations. The next two lines create a new image that stores the image in values of Hue (color), Saturation, and Value (HSV) instead of the Red, Green, and Blue (RGB) pixel values of the original image. Converting to HSV focuses your processing...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image