Capture left mouse click on moving objects in live video
조회 수: 1 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!