import java.awt.Robot;%Add package or class to current import listimport java.awt.event.*;robot = Robot();objvideoinput('winvideo',2);%to set the device ID and supported format set(obj, 'FramesPerTrigger', Inf);% trigger infinite set(obj, 'ReturnedColorspace', 'rgb')%video in RGB format obj.FrameGrabInterval = 5;%the object acquires every %5th frame from the video stream start(obj)% to start the vedio time=0;NumberOfFrames=while(true)data=getsnapshot(obj);image(data);filas=size(data,1);columnas=size(data,2);% Centercentro_fila=round(filas/2);centro_columna=round(columnas/2);figure(1);if size(data,3)==3data=rgb2gray(data);% Extract edges.BW = edge(data,'canny')[H,T,R] = hough(BW,'RhoResolution',0.5,'Theta',-90:0.5:89.5);endsubplot(212)piel=~im2bw(data,0.19);piel=bwmorph(piel,'close');piel=bwmorph(piel,'open');piel=bwareaopen(piel,275);piel=imfill(piel,'holes');imagesc(piel);% Tagged objects in BW imageL=bwlabel(piel);% Get areas and tracking rectangleout_a=regionprops(L);% Count the number of objectsN=size(out_a,1);if N < 1 || isempty(out_a) % Returns if no object in the imagesolo_cara=[ ];continue end % Select larger area areas=[out_a.Area];[area_max pam]=max(areas);subplot(211)imagesc(data);colormap grayhold on rectangle('Position',out_a(pam).BoundingBox,'EdgeColor',[1 0 0],...'Curvature', [1,1],'LineWidth',2)centro=round(out_a(pam).Centroid);X=centro(1);Y=centro(2);robot.mouseMove(X,Y);text(X+10,Y,['(',num2str(X),',',num2str(Y),')'],'Color',[1 1 1])if X<centro_columna && Y<centro_fila
title('Top left')elseif X>centro_columna && Y<centro_fila
title('Top right')elseif X<centro_columna && Y>centro_fila
title('Bottom left')else
title('Bottom right')