element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog Cam-e-lot - Round 4 - Man vs blobs
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 29 Aug 2014 4:02 PM Date Created
  • Views 628 views
  • Likes 0 likes
  • Comments 3 comments
  • forget_me_not
  • iot_cam-e-lot
Related
Recommended

Cam-e-lot - Round 4 - Man vs blobs

amgalbu
amgalbu
29 Aug 2014

In this post we will face some image processing technique, like blob analysys.

I will use the cvBlob library to detect blobs in the image capture by the raspicam

 

So, let's start.

 

Step1: cvBlob installation

  1. 1.       Download cvBlob library from this link

               https://github.com/Steelskin/cvblob

               and save it to /home/pi/cvblob

 

  1. 2.       Because I downloaded the zip file, I need to unzip it

               tar xvf cvblob-0.10.4-src.zip

 

  1. 3.       We need to make some bug fixing (actually I discovered this bugs while debugging the application I was developing, but in this tutorial I think you can make the utmost out of my headaches :-)). So move to the source code directory

cd cvblob

cv cvBlob

and make the following  changes to

  1. a.       cvblob.h: at line 84 replace

const char cvChainCodeMoves[8][2] = { {0, -1},

with

const signed char cvChainCodeMoves[8][2] = { {0, -1},

  1. b.      cvlabel.cpp: at line 34 replace

const char movesSE[4][3][4] = <line continues...>

with

const signed char movesSE[4][3][4] = <line continues...>

  1. c.       cvlabel.cpp: at line 40 replace

const char movesI[4][3][4] = <line continues...>

with

const signed char movesI[4][3][4] = <line continues...>

 

 

  1. 4.       build cvBlob library

               cd ..

     cmake .

     make

 

  1. 5.       and finally let's install the cvBlob library

               make install

 

 

Step2: develop an application that can detect blobs in images

The full source for the application is attached to this post

  1. 1.       I firstly created some utility functions to capture images from RaspiCam. You can find such functions in raspistill.h and raspistill.c (everything is under development, so some code clean up may be required..). Thanks to raspistill functions, the main application is very easy to implement:

         raspistill_initialize(&state);

     raspistill_shot(&state, camera_callback);

     raspistill_terminate(&state);

 

               The raspistill_shot take a photo and invoke the camera_callback function. The only      parameter used by this function is an IplImage object that contains the captured image

 

  1. 2.       Next step is to implement functions for detecting blobs in the image. Such functions are implemented in the blobs.c and blobs.h functions. There are two functions currently implemented

         detectBlobs(IplImage* image, struct ImageParams* imageParams)

              

               and

         detectBlobsWithImage(IplImage* image, struct ImageParams* imageParams)

 

                The second one shows the results of the image processing in a set of windows. So I'm going to use the latter for this demo because it's more impressive than some text output on a console. This function basically gets the images captured by the RaspiCam and creates an image (named segmentated) where the pixel whose color is inside the given RGB color range are white and the other pixels are black

IplImage* segmentated;

cvInRangeS(image, CV_RGB(155, 0, 0), CV_RGB(255, 130, 130), segmentated);

 

With the segmentated image, we can detect blobs

IplImage* labelImg;
CvBlobs blobs;
labelImg = cvCreateImage(cvGetSize(image), IPL_DEPTH_LABEL, 1);
 
result = cvLabel(segmentated, labelImg, blobs);

 

and finally we can apply a filter on the blob area to discard blobs that are too small

 

cvFilterByArea(blobs, 500, 1000000);

 

  1. 3.       Let's bring everything together and make  loop that periodically invoke the raspistill_shot function so that we can experiment with the camera and it's behavior in different light conditions

 

  1. 4.       Let's build application with the usual sequence of commands

               cd build

     cmake ..

     make

 

  1. 5.       Finally run the application

               ./camelot

 

Soon the video where you will see the results of all these efforts. Enjoy it!!

Attachments:
App.zip
  • Sign in to reply
  • vish
    vish over 11 years ago in reply to DAB

    No need to learn openCV as a whole unless you want to go to scientific computing on image processing. Both Processing and openframeworks have very descent abstraction of openCV inbuilt. You can start by exploring them. For most of the proto projects, it's more than enough.

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

    Opencv is another program I wish I had time to learn.

    It has so many possibilities for people with inquisitive minds and visual esthetics.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ipv1
    ipv1 over 11 years ago

    There is a book under the orieley publishers for opencv. Good ready and you might find it useful.

    • 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