Capture left mouse click on moving objects in live video

3 vues (au cours des 30 derniers jours)
Sam
Sam le 10 Juin 2020
Hello,
I am trying to write a small program which displays a video and captures left mouse clicks on this live video.
The video displays 5 objects, which randomly start and stop moving. Every time an object moves, it has to be clicked on (by a left mouse click).
My code so far:
vid = VideoReader('test1.mp4');
ax = axes;
hfig = figure(1);
set(hfig,'WindowButtonDownFcn',@countclicks)
while vid.hasFrame()
temp = vid.readFrame();
imshow(temp,'Parent',ax);
pause(1/vid.FrameRate);
end
function countclicks(gcbo,eventdata,handles)
disp('click')
end
This code seems to work because when I click on the video, 'click' is displayed by Matlab. Except, when I have to click on 3 simultaneously moving objects really fast, it doesn't capture every mouse click... Changing the value for the pause seems to help, but than the video doesn't play fast enough. Is there another way to reach my goal?
Thanks!

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by