element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STEM Projects
  • Learn
  • Learning Center
  • STEM Academy
  • STEM Projects
  • More
  • Cancel
STEM Projects
Blog Book Carrying Robot #3 color detection and calibration algorithm
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STEM Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: mohanedessam
  • Date Created: 11 Aug 2015 5:58 AM Date Created
  • Views 652 views
  • Likes 2 likes
  • Comments 2 comments
  • image_processing
  • teachers_pet
  • matlab_raspberry_pi
  • raspberry_pi
  • matlab
  • raspberry_pi_2
  • teachers pet robotics design challenge
  • book_carrying_robot
Related
Recommended

Book Carrying Robot #3 color detection and calibration algorithm

mohanedessam
mohanedessam
11 Aug 2015

After installing Matlab with Raspberry PI as shown in my previous post I show a simple algorithm for color detection and calibration on Matlab and implement that on Raspberry PI. this is the first step for the robot to detect it's route which is marked using colors.

 

First, brief explanation of the color detection methodology.

the color detection is done using what's called trichromatic coefficients of the colors (you can refer to the very famous text digital image processing by gonzalez Page: 224). this method provides better robustness in terms of brightness differences.

For the coding of that, these coefficients are always less than one, so it's turned into percentage-like values by multiplying by 100 to ease the processing in programming.

the code used is attached (mohaned_code.m) and a snap shot from running this code using PI is shown here (also a photo of the robot and a photo after using a blue paper to cover the body to protect from interfering colors):

image

image

image

 

Second, it's very important to calibrate the max-min percentages for each color based on the exact objects to be detected later during the project run.

although, as mentioned before calibrating for various color intensities is important but not so severe due to using the trichromatic coefficients.

the calibration process is done using the attached code segment (RGB_percent_cal.m) and this video explains how it's done:

first an image is taken.

MATLAB imcrop function is used to manually segment the required object.

the program calculates the maximum and minimum RGB percentages over the whole selected region.

this process should be repeated for all required objects and the final RGB percentage values is the Union of all the partial regions.

 

Video Link on Youtube:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

http://youtu.be/Vl3ieVp5nCc

 

next step is to run the motors using Raspberry PI PWM pins.

Attachments:
mohaned_code.m.zip
RGB_percent_cal.m.zip
start_pi.m.zip
turnoff_pi.m.zip
  • Sign in to reply
  • mohanedessam
    mohanedessam over 9 years ago in reply to DAB

    I basically calibrate using a picture of the object to be detected and calculating the relative densities of the RGB color components (e.g. percent_r = 100*( r/(r+g+b) ) ); I use a MATLAB cropping tool to segment only the object I need from the picture; and getthe RGB relative densities for all the points in the object; that gives me some range (min-to-max) for each color component R,G,B; I redo this for all the objects that I want to detect then I combine all the resulting ranges from all objects; and I use this combined range to detect my objects of interest while operating the algorithm.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Could you provide more description on your color analysis algorithm?

     

    I think I know what you are doing, but I am not familiar with the Matlab terms.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube