Thread Subject: Problem with mmreader and capture frame

Subject: Problem with mmreader and capture frame

From: Alric Gta

Date: 4 Jun, 2009 10:57:00

Message: 1 of 4

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

Subject: Problem with mmreader and capture frame

From: Leslie McBrayer

Date: 4 Jun, 2009 13:18:21

Message: 2 of 4

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

This may be related to a known bug in mmreader, which has a workaround.
See:

http://www.mathworks.com/support/bugreports

and search for mmreader and/or 536560.

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

Try changing

> frame=get(handles.counter,'String')

to

frame = str2num(get(handles.counter,'String'))

Subject: Problem with mmreader and capture frame

From: Alric Gta

Date: 4 Jun, 2009 15:55:03

Message: 3 of 4


Thanks for the help is working with:

frame = str2num(get(handles.counter,'String'))

but what about those horizontal lines (see the picture at the link that I have posted)

Why does extract the frame like that and how can I fix this really need the image to be seen perfect.

What other function(like read) I could use to extract a specific frame from my video.

Just a little help.

Subject: Problem with mmreader and capture frame

From: Leslie McBrayer

Date: 4 Jun, 2009 16:03:09

Message: 4 of 4


"Alric Gta" <alric2rei@yahoo.com> wrote in message
news:h08qon$c09$1@fred.mathworks.com...
>
> Thanks for the help is working with:
>
> frame = str2num(get(handles.counter,'String'))
>
> but what about those horizontal lines (see the picture at the link that I
> have posted)
>
> Why does extract the frame like that and how can I fix this really need
> the image to be seen perfect.
>
> What other function(like read) I could use to extract a specific frame
> from my video.
>
> Just a little help.

Assuming you're on a Windows system, try the workaround for bug ID #536560
here:

http://www.mathworks.com/support/bugreports/search_results?search_executed=1&keyword=mmreader&release_filter=Exists+in&release=160&selected_products=


Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
getframe Sprinceana 22 Jun, 2009 04:39:33
mmreader Sprinceana 22 Jun, 2009 04:39:33
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com