Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Virtual Pen in MATLAB

clc

clear all

close all

warning off

centroids=[];

c=webcam;

while true

e=c.snapshot;

mkdir=createMask(e);

mkdir=imfill(mkdir,'holes');

mkdir=bwareaopen(mkdir,20);

BW = bwareafilt(mkdir, 1);

L = bwlabel(BW);

s = regionprops(L, 'centroid');

centroids =[centroids;cat(1, s.Centroid)];

if(~isempty(centroids))

    subplot(1,2,1);

    imshow(e);

    subplot(1,2,2);

    imshow(e);

    hold on

plot(centroids(:,1), centroids(:,2),'r-','linewidth',3);

else

    subplot(1,2,1);

    imshow(e);

    subplot(1,2,2);

    imshow(e);

end

drawnow;

hold off

end

 


Join us on Telegram: https://t.me/matlabcastor

No comments

Popular Posts

Followers