do i have to learn java in order to use java packages in my MATLAB code?
显示 更早的评论
i'm doing this project in which i'll be moving my mouse using my webcam. so the code has imported some java packages. i have no experiance in java. how can i understand the code. and to write more codes like this, do i have to learn java or i can simply use MATLAB? below is my code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
import java.awt.Robot;
import java.awt.event.*;
mouse = Robot;
vid = videoinput('winvideo', 1);
preview(vid);
for f=1:1000
d=getsnapshot(vid);
d = imresize(d,[480 640]);
i=im2bw(d,.56);
[label num]=bwlabel(i,8);
stats = regionprops(label,'all');
ind= find([stats.Area] < 8000 );
if (num==1)
xx=stats(ind).Centroid(1);
xx=(1366-(xx*2.14));
xx
yy=stats(ind).Centroid(2);
yy=yy*1.6;
yy
mouse.mouseMove(xx, yy);
elseif(num>1)
mouse.mousePress(InputEvent.BUTTON1_MASK);
mouse.mouseRelease(InputEvent.BUTTON1_MASK);
mouse.mousePress(InputEvent.BUTTON1_MASK);
mouse.mouseRelease(InputEvent.BUTTON1_MASK);
end
pause(.001);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
i need to understand this code ASAP
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Call Java from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!