Video is displayed smaller in figure
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dear Matlab users / Mathworks,
I want to play a movie in a figure and want that the figure has the same size as the movie (e.g. setting the figure position properties equal to the video width and height). When doing this, the figure is bigger than the movie played (see the blue marked area):
I've reproduced the same behavior with a mathworks example and default movie:
clear
close all
clc
vid = VideoReader('xylophone.mp4');
mov = struct('cdata',zeros(vid.Height,vid.Width,3,'uint8'),'colormap',[]);
% Read all frames
k = 1;
while hasFrame(vid)
mov(k).cdata = readFrame(vid);
k = k+1;
end
hf = figure;
hf.Position = [150 150 vid.Width vid.Height];
hf.MenuBar = 'none';
movie(hf,mov,1,vid.FrameRate);
Also changing other figure properties (e.g. InnerPosition or OuterPosition) didn't seem to help.
Can you please advise on how to change this behavior?
I am running the following install:
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.2.0.556344 (R2017a)
Operating System: Microsoft Windows 7 Enterprise Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 9.2 (R2017a)
Control System Toolbox Version 10.2 (R2017a)
Curve Fitting Toolbox Version 3.5.5 (R2017a)
GUI Layout Toolbox Version 2.3 (R2016b)
MATLAB_TFIGURE Version 4.0
Signal Processing Toolbox Version 7.4 (R2017a)
System Identification Toolbox Version 9.6 (R2017a)
Thanks in advanced!
Kind regards,
Geert-Jan
----------------------------------------------
Note: the default figure units are 'pixels'. When switching to 'points' it makes the boundary's even bigger.
Note 2: It seems to work fine in on an old R2012a install I still heve. But the problem is present in R2017a.
0 comentarios
Respuestas (1)
Shashank
el 10 de Jul. de 2017
Hi Geert-Jan,
I tried running the example code that you mentioned in MATLAB R2017a. However, I am unable to reproduce the issue that you have specified. Here is a function that I have created which might be helpful for you:
function playVideo(filename)
videoReader = VideoReader(filename);
videoHeight = videoReader.Height;
videoWidth = videoReader.Width;
videoStruct = struct('cdata', zeros(videoHeight, videoWidth, 3, 'uint8'), 'colormap', []);
numberOfFrames = 1;
while hasFrame(videoReader)
videoStruct(numberOfFrames).cdata = readFrame(videoReader);
numberOfFrames = numberOfFrames + 1;
end
set(gcf, 'position', [150, 150, videoWidth, videoHeight]);
set(gca, 'units', 'pixels');
set(gca, 'position', [0, 0, videoWidth, videoHeight]);
movie(videoStruct, 1, videoReader.FrameRate);
end
- Shashank
1 comentario
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!