<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252892</link>
    <title>MATLAB Central Newsreader - Problem with mmreader and capture frame</title>
    <description>Feed for thread: Problem with mmreader and capture frame</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 04 Jun 2009 10:57:00 -0400</pubDate>
      <title>Problem with mmreader and capture frame</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252892#654619</link>
      <author>Alric Gta</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I read a movie with the function mmreader and I tried to extract a specific frame from my video.I have extracted the frame but has lots of horizontal lines and I can see anything.   ==== Why ???&lt;br&gt;
&lt;br&gt;
I need to do this in Matlab &lt;br&gt;
&lt;br&gt;
I mean I want to run the movie in matlab WM player and when I hit the pause button to extract the frame that I see on my player.&lt;br&gt;
&lt;br&gt;
To know wich one need to be extracted I use a counter.&lt;br&gt;
&lt;br&gt;
Here is my code:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
It make some lines on my images and I can see anything&lt;br&gt;
&lt;br&gt;
see the link below:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://i361.photobucket.com/albums/oo54/Rikom/frame58.png&quot;&gt;http://i361.photobucket.com/albums/oo54/Rikom/frame58.png&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
My GUI see link below:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://i361.photobucket.com/albums/oo54/Rikom/MyGui2.png&quot;&gt;http://i361.photobucket.com/albums/oo54/Rikom/MyGui2.png&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
==============&lt;br&gt;
&lt;br&gt;
I want to run the video in matlab WMPlayer( it is working no problem in here) and&lt;br&gt;
when I push the pause button I want to extract the current Frame (I have done a counter to count my frames, to know wich one to extract)&lt;br&gt;
&lt;br&gt;
Problems need to be solved :&lt;br&gt;
&lt;br&gt;
1. Why when I use&lt;br&gt;
poza=read(handles.film,58) % extract frame 58 it makes the img with lines on it see first link&lt;br&gt;
2. When I use&lt;br&gt;
&lt;br&gt;
frame=get(handles.counter,'string'); % frame = 58 or the value when I push the pause button&lt;br&gt;
&amp;nbsp;poza=read(handles.film,frame);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;==================================================&lt;br&gt;
it gives me this err:&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; mmreader.read at 81&lt;br&gt;
INDEX must be a numeric scalar or 1x2 vector.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; myvid&amp;gt;pause_Callback at 160&lt;br&gt;
poza=read(handles.film,frame);&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; gui_mainfcn at 96&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;feval(varargin{:});&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; myvid at 42&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gui_mainfcn(gui_State, varargin{:});&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; @(hObject,eventdata)myvid('pause_Callback',hObject,eventdata,guidata(hObject))&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&lt;br&gt;
??? Error using ==&amp;gt; pause&lt;br&gt;
Error while evaluating uicontrol Callback&lt;br&gt;
===================================================&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
My code :&lt;br&gt;
&lt;br&gt;
function myvid_OpeningFcn(hObject, eventdata, handles, varargin)&lt;br&gt;
% This function has no output args, see OutputFcn.&lt;br&gt;
% hObject handle to figure&lt;br&gt;
% eventdata reserved - to be defined in a future version of MATLAB&lt;br&gt;
% handles structure with handles and user data (see GUIDATA)&lt;br&gt;
% varargin command line arguments to myvid (see VARARGIN)&lt;br&gt;
&lt;br&gt;
% Choose default command line output for myvid&lt;br&gt;
handles.output = hObject;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
set(gcf,'Color',[0.7 0.7 0.7]); % gcf=get current figure handle si seteaza culoarea asa1=[0 0 0] si asa2=[0.7 0.7 0.7]&lt;br&gt;
pos=[10 100 800 800]; % pos player&lt;br&gt;
% m=figure;&lt;br&gt;
MovieControl = actxcontrol('WMPlayer.OCX.7',pos)&lt;br&gt;
% set(MovieControl,'uiMode','none'); % ca sa dispara bara de optiuni de jos player-ului&lt;br&gt;
assignin('base','MovieControl',MovieControl);&lt;br&gt;
get(MovieControl)&lt;br&gt;
set(MovieControl.settings,'autoStart',0);&lt;br&gt;
handles.film=mmreader('y.avi');&lt;br&gt;
&lt;br&gt;
%================================================&lt;br&gt;
&lt;br&gt;
function open_Callback(hObject, eventdata, handles)&lt;br&gt;
% hObject handle to open (see GCBO)&lt;br&gt;
% eventdata reserved - to be defined in a future version of MATLAB&lt;br&gt;
% handles structure with handles and user data (see GUIDATA)&lt;br&gt;
&lt;br&gt;
[filename pathname] = uigetfile('*.*','Please select a file')&lt;br&gt;
&lt;br&gt;
if ~filename&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;br&gt;
end;&lt;br&gt;
&lt;br&gt;
file1=[pathname filename]&lt;br&gt;
[path,name,ext,ver] = fileparts(file1);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
mp= evalin('base', 'MovieControl');&lt;br&gt;
mp.URL=[pathname filename];&lt;br&gt;
&lt;br&gt;
handles.film=mmreader(mp.URL)&lt;br&gt;
% poza=frame2im(handles.film(30));&lt;br&gt;
% figure,imshow(poza);&lt;br&gt;
&lt;br&gt;
guidata(hObject, handles)&lt;br&gt;
%===============================================&lt;br&gt;
&lt;br&gt;
function start_Callback(hObject, eventdata, handles)&lt;br&gt;
% hObject handle to start (see GCBO)&lt;br&gt;
% eventdata reserved - to be defined in a future version of MATLAB&lt;br&gt;
% handles structure with handles and user data (see GUIDATA)&lt;br&gt;
set(handles.start,'UserData',1);&lt;br&gt;
mp= evalin('base', 'MovieControl')&lt;br&gt;
mp.controls.play&lt;br&gt;
while (get(handles.start,'UserData') ==1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%increments the counter&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp = str2num(get(handles.counter,'String'));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp = temp + 1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.counter,'String',num2str(temp));&lt;br&gt;
&amp;nbsp;pause(0.040);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%&quot;flushes the event queue&quot; and updates the figure window&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%since Matlab is a single thread process, this command is requierd&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;drawnow&lt;br&gt;
end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
guidata(hObject, handles);&lt;br&gt;
&lt;br&gt;
%=========================================&lt;br&gt;
&lt;br&gt;
function pause_Callback(hObject, eventdata, handles)&lt;br&gt;
% hObject handle to pause (see GCBO)&lt;br&gt;
% eventdata reserved - to be defined in a future version of MATLAB&lt;br&gt;
% handles structure with handles and user data (see GUIDATA)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
mp= evalin('base', 'MovieControl')&lt;br&gt;
mp.controls.pause&lt;br&gt;
set(handles.start,'UserData',0);&lt;br&gt;
frame=get(handles.counter,'String')&lt;br&gt;
&lt;br&gt;
% vidFrame = getframe(gcf);&lt;br&gt;
% poza=frame2im(vidFrame);&lt;br&gt;
poza=read(handles.film,58);&lt;br&gt;
&amp;nbsp;figure,imshow(poza);&lt;br&gt;
%================================================&lt;br&gt;
&lt;br&gt;
Thanks and hope somebody can help me </description>
    </item>
    <item>
      <pubDate>Thu, 04 Jun 2009 13:18:21 -0400</pubDate>
      <title>Re: Problem with mmreader and capture frame</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252892#654654</link>
      <author>Leslie McBrayer</author>
      <description>&amp;gt; I read a movie with the function mmreader and I tried to extract a &lt;br&gt;
&amp;gt; specific frame from my video.I have extracted the frame but has lots of &lt;br&gt;
&amp;gt; horizontal lines and I can see anything.   ==== Why ???&lt;br&gt;
&lt;br&gt;
This may be related to a known bug in mmreader, which has a workaround. &lt;br&gt;
See:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/support/bugreports&quot;&gt;http://www.mathworks.com/support/bugreports&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
and search for mmreader and/or 536560.&lt;br&gt;
&lt;br&gt;
&amp;gt; 2. When I use&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; frame=get(handles.counter,'string'); % frame = 58 or the value when I push &lt;br&gt;
&amp;gt; the pause button&lt;br&gt;
&amp;gt; poza=read(handles.film,frame);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ==================================================&lt;br&gt;
&amp;gt; it gives me this err:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; mmreader.read at 81&lt;br&gt;
&amp;gt; INDEX must be a numeric scalar or 1x2 vector.&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
Try changing&lt;br&gt;
&lt;br&gt;
&amp;gt; frame=get(handles.counter,'String')&lt;br&gt;
&lt;br&gt;
to&lt;br&gt;
&lt;br&gt;
frame = str2num(get(handles.counter,'String')) </description>
    </item>
    <item>
      <pubDate>Thu, 04 Jun 2009 15:55:03 -0400</pubDate>
      <title>Re: Problem with mmreader and capture frame</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252892#654695</link>
      <author>Alric Gta</author>
      <description>&lt;br&gt;
Thanks for the help is working with:&lt;br&gt;
&lt;br&gt;
frame = str2num(get(handles.counter,'String')) &lt;br&gt;
&lt;br&gt;
but what about those horizontal lines (see the picture at the link that I have posted)&lt;br&gt;
&lt;br&gt;
Why does extract the frame like that and how can I fix this really need the image to be seen perfect.&lt;br&gt;
&lt;br&gt;
What other function(like read) I could use to extract a specific frame from my video.&lt;br&gt;
&lt;br&gt;
Just a little help.</description>
    </item>
    <item>
      <pubDate>Thu, 04 Jun 2009 16:03:09 -0400</pubDate>
      <title>Re: Problem with mmreader and capture frame</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252892#654700</link>
      <author>Leslie McBrayer</author>
      <description>&lt;br&gt;
&quot;Alric Gta&quot; &amp;lt;alric2rei@yahoo.com&amp;gt; wrote in message &lt;br&gt;
news:h08qon$c09$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks for the help is working with:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; frame = str2num(get(handles.counter,'String'))&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; but what about those horizontal lines (see the picture at the link that I &lt;br&gt;
&amp;gt; have posted)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Why does extract the frame like that and how can I fix this really need &lt;br&gt;
&amp;gt; the image to be seen perfect.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; What other function(like read) I could use to extract a specific frame &lt;br&gt;
&amp;gt; from my video.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Just a little help.&lt;br&gt;
&lt;br&gt;
Assuming you're on a Windows system, try the workaround for bug ID #536560 &lt;br&gt;
here:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/support/bugreports/search_results?search_executed=1&amp;keyword=mmreader&amp;release_filter=Exists+in&amp;release=160&amp;selected_products=&quot;&gt;http://www.mathworks.com/support/bugreports/search_results?search_executed=1&amp;keyword=mmreader&amp;release_filter=Exists+in&amp;release=160&amp;selected_products=&lt;/a&gt;</description>
    </item>
  </channel>
</rss>

