Color Detection and Tracking Using USB cam
조회 수: 15 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (2개)
Redha Reghioua
2020년 9월 30일
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
2024년 11월 5일 4:07
See my attached video tracking demo where I track the movement of a green Sharpie marker.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!