Escolar Documentos
Profissional Documentos
Cultura Documentos
Ok, i consider all points above have explained what i did. Codes below will demonstrate all points above. Take a look:
clear all; close all; clc; caminf = imaqhwinfo; mycam = char(caminf.InstalledAdaptors(end)); mycaminfo = imaqhwinfo(mycam); resolution = char(mycaminfo.DeviceInfo.SupportedFormats(end)); vid = videoinput(mycam, 1, resolution); set(vid, 'FramesPerTrigger', Inf); set(vid, 'ReturnedColorspace', 'rgb'); vid.FrameGrabInterval = 3; screenSize = get(0, 'screensize'); width=screenSize(3); height=screenSize(4);
% processing diff_im = imsubtract(data(:,:,1), rgb2gray(data)); % originale diff_im = medfilt2(diff_im, [3 3]); diff_im = im2bw(diff_im,0.2); diff_im = bwareaopen(diff_im,80); bw=bwconncomp(diff_im,8); stats = regionprops(bw, 'Centroid'); imshow(data) hold on % placing centroid if length(stats)>1 cent = stats(1).Centroid; plot(cent(1),cent(2), '-go','MarkerFaceCOlor','g','MarkerSize',10); % moving mouse and callibration with window size import java.awt.Robot; import java.awt.event.*; mouse=Robot; mouse.mouseMove(round((width/640)*cent(1)),... round((height/480)*cent(2))); end hold off flushdata(vid); % to clear memory end stop(vid); delete(vid); imaqreset; % originale by Jans Hendry % UGM, Indonesia