4.2

4.2 | 6 ratings Rate this file 145 Downloads (last 30 days) File Size: 2.6 KB File ID: #40154
image thumbnail

How to Detect and Track Red, Green and Blue Colored Object in LIVE Video

by

 

04 Feb 2013 (Updated )

This code can detect and track Red, Green and Blue colored objects in LIVE video.

| Watch this File

File Information
Description

This code can detect and track Red, Green and Blue colored objects in LIVE video. In this code objects can be segmented using color detection and segmentation.
For detail documentation: http://arindambose.com/blog/?p=82

For video tutorial:
http://youtu.be/QPzynkdsuW8

Required Products Image Acquisition Toolbox
Computer Vision System Toolbox
MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (21)
20 Mar 2014 chaitanya

Excellent work sir, i saw your video as well but when i am running code i am getting error as :

Undefined variable "imaq" or class "imaq.VideoDevice".

Error in RGB_Detection_and_Tracking (line 14)
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ... % Acquire input video stream

can you please help
thanks in advance

27 Dec 2013 daher

hi, how to tag and track the first identified colored object, for example, in a video when other objects will appear with the same color without referring to geometry

28 Nov 2013 Verena

Hello, thanks you so much!

@CHANDAN Nagaraja did you find any solution for your problem? I have the same problem ;)

14 Nov 2013 CHANDAN Nagaraja

Thank you so much.
I was wondering can we store all the X,Y vales of red object as output in MATlab code? Do you know code for it?

12 Nov 2013 Loai

hello, first I wanted to thank u and i wanted to ask what should i do if i want it to follow a combination of RGB and return its area

05 Oct 2013 Muhmmmad usman

Hello dear! I am getting error during running code. please help me with this. Below i have written down that error. your help will be highly appreciated. Thanks
??? Undefined variable "imaq" or class "imaq.VideoDevice".

07 Sep 2013 Renato Henz

Hello everyone! I'm getting this error while trying to run the program:

??? Undefined variable "imaq" or class "imaq.VideoDevice".

Error in ==> RGB_Detection_and_Tracking at 14
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ... % Acquire input video
stream

Does anyone know what might be happening, or how can I fix it?
Thanks a lot!

14 Jul 2013 ADNAN

gud job

30 May 2013 Elizabeth

Hi, I was wondering if it would be possible to change the input from LIVE video to recorded video?

11 Mar 2013 swapna chougule

@Arindam Bose thank you

11 Mar 2013 Arindam Bose

@swapna chougule: The number of red pixels are given in terms of area of corresponding blob. Look into area property of each blob.

08 Mar 2013 swapna chougule

how to get number of pixels of red color using in this code??

24 Feb 2013 mohammed ghazal

ok thnx bro

23 Feb 2013 Arindam Bose

@mohammed ghazal: Red, Green and Blue are the basic colors. The simple code segment which subtracts the intensity image from the corresponding layer, can be used only for detecting these three basic colors. But if you need to detect more colors you have to convert the image into HSV color map and prepare different threshold filters for different colors in Hue layer.

23 Feb 2013 mohammed ghazal

thnx dear my copy of matlab2012b don't have computer vision toolbox installed,so i installed the old version2012a...and it is worked ok...thnx alot
tell me pls how to determine color Threshold ... what is the rule ? i want
to track more colors
redThresh = 0.24; % Threshold for red detection
greenThresh = 0.05; % Threshold for green detection
blueThresh = 0.15; % Threshold for blue detection

22 Feb 2013 Arindam Bose

@mohammed ghazal The problem is that you don't have computer vision toolbox installed in your MATLAB version. This special toolbox comes with newer
version of MATLAB e.g. R2012a onwards. The Blob analysis handles does the statistical analysis of detected blobs in a logical image. However you can use 'regionprops' command instead of vision.blobAnalysis. It does almost same job. Dig into the help for more information about it.
Anyway you can collect the newer version of MATLAB. MATLAB R2013a has already been released. Always stay updated to experience more.

22 Feb 2013 mohammed ghazal

how to solve this error pls?

Undefined variable "vision" or class "vision.BlobAnalysis".

Error in RGB_Detection_and_Tracking (line 19)
hblob = vision.BlobAnalysis('AreaOutputPort', false, ... % Set blob
analysis handling

13 Feb 2013 Arindam Bose

@Masoud : Because, I used a while loop in the middle of code and set the loop counter to around 300 frames. So theoretically it will run for 10 seconds(30fps). You can change the loop counter to several thousand. I did not make the loop counter Inf because it will cause a little inconvenience. In that case you have to release the camera handle individually by running this code piece "release(vidDevice)".
So its better to have a loop counter. You can change it to several thousands to run it for several minutes. I made it smaller for demonstration.

12 Feb 2013 Masoud Ghanbari

Hi
Why this program will close after several seconds automatically???

11 Feb 2013 Fiem

Thanks a lot

11 Feb 2013 Fiem  
Updates
04 Feb 2013

Description updated

19 Feb 2013

1. Memory management enhanced
2. Description changed

21 Feb 2014

Description Changed

Contact us