I am currently working on "Image acquisition and tracking" by Ample Hout. I have problem tracking my green laser dot and I dont really understand the coding in follows:
% calculate the midpoints of the area
if leftMost ~= xResolution && rightMost ~= 0
% both leftMost and RightMost have been updated
laserFound = true;
laserX = (leftMost + rightMost)/2;
laserY = (topMost + bottomMost)/2;
% top left: 172,101
% bottom right: 285,185
canvasLaserX = (laserX-172)*320/(285-172);
canvasLaserY = (laserY-101)*240/(185-101);
writefile(floor(canvasLaserX),floor(canvasLaserY));
else
% unable to find laser
laserFound = false;
end
Futhermore, I not really understand for the ploting
% plot laser area
% for ease of viewing, y coordinates are viewed flipped around into
% the cartesian system instead of image coordinate system
if laserFound == true
sfigure(1);
hold on;
plot([0:xResolution],laserY*ones(1, xResolution+1),'w');
plot(laserX*ones(1, yResolution+1),[0:yResolution],'w');
plot(canvasLaserX,canvasLaserY,'mx'); % canvas-scaled laser pixel
hold off;
axis([0 xResolution 0 yResolution]);
drawnow;
end
What does laserY*ones(1, xResolution+1) means? And what is 'mx'? What is these canvasLaser purpose?
Please do kindly advice. I am very appreciate it.