how to get pixel coordinates in implay
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
Is there a way to get the mouse onclick x,y pixel coordinates when playing a movie in implay.
0 commentaires
Réponse acceptée
Jayanti
le 19 Déc 2024
Modifié(e) : Jayanti
le 19 Déc 2024
Hi Juergen,
The“implay”function in MATLAB does not provide direct access to pixel coordinates on click event.
Alternatively you can try achieving this through custom implementation by using “VideoReader”to read video frames and displaying them in a MATLAB figure where you can capture mouse events.
Please refer to the below code:
videoReader = VideoReader('file.mp4');
hFig = figure;
while hasFrame(videoReader)
frame = readFrame(videoReader);
imshow(frame, 'Parent', gca);
[x, y, button] = ginput(1);
if ~isempty(button)
fprintf('Clicked at X: %f, Y: %f\n', x, y);
end
pause(1/videoReader.FrameRate);
end
The video will be paused at each frame, where “ginput” function captures the x and y coordinates of a mouse click, which will be printed to the command window.
Please refer to the documentation link on “ginput” for your reference:
Hope this will be useful!
2 commentaires
Jayanti
le 20 Déc 2024
Hi Juergen,
In the above implementation, we extract each frame individually instead of playing the video. This allows us to capture mouse events. If you don't want to click on a frame, you can press the "Return" key. This will proceed to the next frame.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!