Copyright (c) 2016, Arindam Bose
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
* Neither the name of the University of Illinois at Chicago nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Shyamrao Ghuge (view profile)
Raphael Ferreira (view profile)
@Mohamed Ashraf , Are you able to run the code normally? Why did my aprace the following error:
Undefined variable "vision" or class "vision.TextInserter".
Error in ROOD (line 25)
htextins = vision.TextInserter('Text', 'Number of White Object(s): %2d', ...
% Set text for number of blobs
How did you define the "vision" object? Because it gave error asking to define "vision".
Raphael Ferreira (view profile)
How did you define the "vision" object? Because it gave error asking to define "vision".
Mohamed Ashraf (view profile)
First of all, great job!
I have a question, how did you determine the threshold for the three colors?
anil kumar (view profile)
Error in ==> RGB_Detection_and_Tracking at 14
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ... % Acquire input video
stream
im getting like this what shall doo
sarang nair (view profile)
Sayan Seth (view profile)
Mukundettan (view profile)
Thank you
Mark Caruana (view profile)
HI how do we find out thresholds of other colors like white what would be the threshold red is 0.24 ..how do you find their trheshold amount
Mark Caruana (view profile)
HI how do we find out thresholds of other colors like white what would be the threshold red is 0.24 ..how do you find their trheshold amount
manjari priya (view profile)
How can we detect different colors of the map image by coding in matlab?
Pavan Singh (view profile)
Hi,
How can you use this for still images with any need for tracking, just want to be able to count number of blocks of certain colours on a still image.
Thanks
Anil kumar (view profile)
this code not working
Anil kumar (view profile)
this code not working
Neelesh Sharma (view profile)
Geart job Arindam, It helped me so much..
Adithya MD (view profile)
awesome job
nmc (view profile)
Do you happen to know how to track the first identified colored object in a video when other objects will appear with the same color without referring to geometry?
hani alsareti (view profile)
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_1280x720', ... % Acquire input video stream 'ROI', [1 1 640 480], ... 'ReturnedColorSpace', 'rgb'); i have an error in code it says undefined variable "imaq" or class "imaq.videoDevice"
i am using R2010a version
Delali Attipoe (view profile)
Hello,
I've been trying to run this on 2015b and I get this error and can't seem to figure it out:
Error using matlab.system.StringSet/checkValues
The empty string is not a valid StringSet string.
Error in matlab.system.StringSet/setValues
Error in matlab.system.StringSet
Error in RGB_Tracking (line 29)
htextinsRed = vision.TextInserter('Text', 'Red : %2d', ... % Set text for number of blobs
Any help would be appreciated.
Thanks,
Del
Syed Asad Ali (view profile)
Hi..sir Arindam Bose please understand me about this intensity formula and threshold for finding green intensity....
r=center(:,:,1);
g=center(:,:,2);
b=center(:,:,3);
green=g-(r/2)-(b/2);
bw=(green>30);
in this formula why use /2...and why g is place before r/2 and b/2..and also why use green>30...why use 30 in this...sir pls ans ASAP
Syed Asad Ali (view profile)
Hi..sir Arindam Bose please understand me about this intensity formula and threshold for finding green intensity....
r=center(:,:,1);
g=center(:,:,2);
b=center(:,:,3);
green=g-(r/2)-(b/2);
bw=(green>30);
in this formula why use /2...and why g is place before r/2 and b/2..and also why use green>30...why use 30 in this...sir pls ans ASAP
Mayur Randive (view profile)
A great work done.
nice working....
chfakht chfakht (view profile)
Hi, i'm getting the following erros can you help me
??? 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
Aju (view profile)
A great work been done. Thank You so much. But can anybody please help me out to correct this error mentioned below?
Error in RGB_Detection_and_Tracking (line 6)
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ... % Acquire input video stream
Abu Shuvom (view profile)
ABHISHEK (view profile)
Hey.
How can I connect this code to UART for serial communication to AVR..?
Can i follow using robot the path of red green & blue color object by using this interface..??
Atif Anwer (view profile)
Hi.
The line "step(hshapeinsBox, rgbFrame, bboxRed, single([1 0 0])); % Instert the red box" wasnt working for me for some reason. However i do recommend an alternate that worked which did work fine for me :
insertShape(rgbFrame, 'Rectangle', bboxRed, 'Color', 'red'); % Insert the red box
Arindam Bose (view profile)
@Nathan: Please change the threshold accordingly. It depends on the ambient color
Nathan (view profile)
Sometimes, Matlab detects blue as green color. :( please help
koushik (view profile)
chaitanya (view profile)
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
daher (view profile)
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
Verena (view profile)
Hello, thanks you so much!
@CHANDAN Nagaraja did you find any solution for your problem? I have the same problem ;)
CHANDAN Nagaraja (view profile)
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?
Loai (view profile)
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
Muhmmmad usman (view profile)
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".
Renato Henz (view profile)
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!
ADNAN (view profile)
gud job
Elizabeth (view profile)
Hi, I was wondering if it would be possible to change the input from LIVE video to recorded video?
swapna chougule (view profile)
@Arindam Bose thank you
Arindam Bose (view profile)
@swapna chougule: The number of red pixels are given in terms of area of corresponding blob. Look into area property of each blob.
swapna chougule (view profile)
how to get number of pixels of red color using in this code??
mohammed ghazal (view profile)
ok thnx bro
Arindam Bose (view profile)
@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.
mohammed ghazal (view profile)
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
Arindam Bose (view profile)
@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.
mohammed ghazal (view profile)
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
Arindam Bose (view profile)
@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.
Masoud Ghanbari (view profile)
Hi
Why this program will close after several seconds automatically???
Fiem (view profile)
Thanks a lot
Fiem (view profile)