Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Problem with mmreader and capture frame
Date: Thu, 4 Jun 2009 10:57:00 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 154
Message-ID: <h0899s$8fo$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1244113020 8696 172.30.248.38 (4 Jun 2009 10:57:00 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 4 Jun 2009 10:57:00 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1749348
Xref: news.mathworks.com comp.soft-sys.matlab:544763


Hi,

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 ???

I need to do this in Matlab 

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.

To know wich one need to be extracted I use a counter.

Here is my code:


It make some lines on my images and I can see anything

see the link below:

http://i361.photobucket.com/albums/oo54/Rikom/frame58.png


My GUI see link below:

http://i361.photobucket.com/albums/oo54/Rikom/MyGui2.png


==============

I want to run the video in matlab WMPlayer( it is working no problem in here) and
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)

Problems need to be solved :

1. Why when I use
poza=read(handles.film,58) % extract frame 58 it makes the img with lines on it see first link
2. When I use

frame=get(handles.counter,'string'); % frame = 58 or the value when I push the pause button
 poza=read(handles.film,frame);

 ==================================================
it gives me this err:

??? Error using ==> mmreader.read at 81
INDEX must be a numeric scalar or 1x2 vector.

Error in ==> myvid>pause_Callback at 160
poza=read(handles.film,frame);

Error in ==> gui_mainfcn at 96
        feval(varargin{:});

Error in ==> myvid at 42
    gui_mainfcn(gui_State, varargin{:});

Error in ==> @(hObject,eventdata)myvid('pause_Callback',hObject,eventdata,guidata(hObject))

 
??? Error using ==> pause
Error while evaluating uicontrol Callback
===================================================




My code :

function myvid_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to myvid (see VARARGIN)

% Choose default command line output for myvid
handles.output = hObject;


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]
pos=[10 100 800 800]; % pos player
% m=figure;
MovieControl = actxcontrol('WMPlayer.OCX.7',pos)
% set(MovieControl,'uiMode','none'); % ca sa dispara bara de optiuni de jos player-ului
assignin('base','MovieControl',MovieControl);
get(MovieControl)
set(MovieControl.settings,'autoStart',0);
handles.film=mmreader('y.avi');

%================================================

function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

[filename pathname] = uigetfile('*.*','Please select a file')

if ~filename
    return
end;

file1=[pathname filename]
[path,name,ext,ver] = fileparts(file1);


mp= evalin('base', 'MovieControl');
mp.URL=[pathname filename];

handles.film=mmreader(mp.URL)
% poza=frame2im(handles.film(30));
% figure,imshow(poza);

guidata(hObject, handles)
%===============================================

function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.start,'UserData',1);
mp= evalin('base', 'MovieControl')
mp.controls.play
while (get(handles.start,'UserData') ==1)
    %increments the counter
    temp = str2num(get(handles.counter,'String'));
    temp = temp + 1;
    set(handles.counter,'String',num2str(temp));
 pause(0.040);
    %"flushes the event queue" and updates the figure window
    %since Matlab is a single thread process, this command is requierd
    drawnow
end
   
guidata(hObject, handles);

%=========================================

function pause_Callback(hObject, eventdata, handles)
% hObject handle to pause (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)


mp= evalin('base', 'MovieControl')
mp.controls.pause
set(handles.start,'UserData',0);
frame=get(handles.counter,'String')

% vidFrame = getframe(gcf);
% poza=frame2im(vidFrame);
poza=read(handles.film,58);
 figure,imshow(poza);
%================================================

Thanks and hope somebody can help me