Color Detection and Tracking Using USB cam

14 vues (au cours des 30 derniers jours)
Pablo Joannes
Pablo Joannes le 5 Oct 2017
Modifié(e) : Walter Roberson le 5 Nov 2024 à 4:12
I'm new to using the MATLAB tool, I'm enjoying it.
I would like the help of you to be able to make recognize colors, like red, through a USB camera. like this one: https://www.mathworks.com/help/vision/examples/face-detection-and-tracking-using-live-video-acquisition.html
Only in this he recognizes the face of people, I wanted with colors ... can you help me?

Réponses (2)

Redha Reghioua
Redha Reghioua le 30 Sep 2020
vid=videoinput('winvideo',1,'YUY2_320x240');
set(vid,'FramesPerTrigger',inf);
set(vid,'ReturnedColorspace','rgb');
vid.FrameGrabInterval=5;
start(vid);
while(vid.FramesAcquired<=100)
data=getsnapshot(vid);
diff_im=imsubtract(data(:,:,2),rgb2gray(data)); % 1= red, 2=green, 3= bleu
diff_im=medfilt2(diff_im,[3,3]);
diff_im=im2bw(diff_im,0.18);
diff_im=bwareaopen(diff_im,300);
bw=bwlabel(diff_im,8);
stats=regionprops(bw,'BoundingBox','Centroid');
imshow(data);
hold on
for(object=1:length(stats))
bb=stats(object).BoundingBox
bc=stats(object).Centroid
rectangle('Position',bb,'EdgeColor','r','LineWidth',2);
plot(bc(1),bc(2),'m+');
end
hold off
end
stop(vid);
flushdata(vid);
clear all

Image Analyst
Image Analyst le 5 Nov 2024 à 4:07
See my attached video tracking demo where I track the movement of a green Sharpie marker.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by