capture frame on click

조회 수: 2 (최근 30일)
SOE CADLAB
SOE CADLAB 2019년 9월 30일
댓글: SOE CADLAB 2019년 10월 20일
how can i capture a frame on mouse click from a video ?
  댓글 수: 1
darova
darova 2019년 9월 30일
I think buttonDownFcn should be used in this case. BUt can't figure out how =(

댓글을 달려면 로그인하십시오.

답변 (1개)

Abhilash Padma
Abhilash Padma 2019년 10월 3일
One of the ways to achieve this task is to play video on axes and use buttonDownFcn of image object. You can try this by typing the following command in your MATLAB prompt which will open an example explaining how to display a video in a custom user interface.
openExample('vision/VideoInCustomGUIExample');
Add the following line in the “displayImage” function of showFrameOnAxis.m
hIm.ButtonDownFcn=@(~,~)imwrite(frame,'a.jpg');
  댓글 수: 2
darova
darova 2019년 10월 3일
I made simple example for gif animation, but can't set up function for buttonDownFcn
Can you please look?
clc,clear
x = linspace(0,4);
y = sin(x);
plot(x,y);
f = getframe;
filename = 'gif_animation.gif';
[im,map] = rgb2ind(f.cdata,256);
imwrite(im,map,filename,'DelayTime',0,'Loopcount',inf);
fcn = @(~,~,im,map)imwrite(im,map,filename,'DelayTime',0.1,'WriteMode','Append');
hold on
for i = 1:length(x)
h = plot(x(i),y(i),'or');
f = getframe(gca);
[im,map] = rgb2ind(f.cdata,256);
set(gca,'buttonDOwnFcn',@(~,~,im,map)fcn(im,map))
pause(0.1)
delete(h)
end
hold off
SOE CADLAB
SOE CADLAB 2019년 10월 20일
thank you but i need to capture that paritular frame on a mouse click

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by