Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
*HELP* Problem with videoinput, preview statement

Subject: *HELP* Problem with videoinput, preview statement

From: Talal Khan

Date: 13 Jan, 2008 23:12:02

Message: 1 of 10

I use this piece of code and it works perfectly in the
matlab environment, however when i make an executable out
of it,it gives me an error saying
----------------------------------------------
Function 'preview' is not defined for a first argument of
class 'videoinput'.
----------------------------------------------
-------------
MY CODE IS:
------------

vid = videoinput('winvideo');

preview(vid);

pause;

frame = getsnapshot(vid);

subplot(1,1,1);imshow(frame,'InitialMagnification','fit');

%save file
 saveas(gca,'TTT.jpeg')
 delete(vid);
 
 closepreview;

-----------------------------------------------
MATLAB VERSION 7.0.1.24704 (R14) Service Pack 1
------------------------------------------------
Image Axquisition Toolbox 1.7
-------------------------------------------------

Subject: *HELP* Problem with videoinput, preview statement

From: Dave Tarkowski

Date: 14 Jan, 2008 14:21:11

Message: 2 of 10

Talal Khan wrote:
> I use this piece of code and it works perfectly in the
> matlab environment, however when i make an executable out
> of it,it gives me an error saying
> ----------------------------------------------
> Function 'preview' is not defined for a first argument of
> class 'videoinput'.
> ----------------------------------------------
> -------------
> MY CODE IS:
> ------------
>
> vid = videoinput('winvideo');
>
> preview(vid);
>
> pause;
>
> frame = getsnapshot(vid);
>
> subplot(1,1,1);imshow(frame,'InitialMagnification','fit');
>
> %save file
> saveas(gca,'TTT.jpeg')
> delete(vid);
>
> closepreview;
>
> -----------------------------------------------
> MATLAB VERSION 7.0.1.24704 (R14) Service Pack 1
> ------------------------------------------------
> Image Axquisition Toolbox 1.7
> -------------------------------------------------

Talal,

In R14 SP1, the PREVIEW command could not be compiled. You can see the
list of functions that will not work with the MATLAB Compiler at
http://www.mathworks.com/products/compiler/compiler_support.html, but
that page is only for the current version. Please note that with the
current version of the MATLAB compiler and the Image Acquisition
Toolbox, the PREVIEW command can be compiled only when used with a user
specified image handle.

-Dave Tarkowski

Subject: *HELP* Problem with videoinput, preview statement

From: Talal Khan

Date: 15 Jan, 2008 01:34:02

Message: 3 of 10

OK thanx. so basically your saying i have to update my
matlab version along with the image acquisition toolbox,
other wise the PREVIEW wont work. ill try doing that.
although i think ill have to pay inorder to get the latest
version. can i not just update it for free or something.

"Talal Khan" <talaltk@mathwork.com> wrote in message
<fme5s2$kk9$1@fred.mathworks.com>...
> I use this piece of code and it works perfectly in the
> matlab environment, however when i make an executable
out
> of it,it gives me an error saying
> ----------------------------------------------
> Function 'preview' is not defined for a first argument
of
> class 'videoinput'.
> ----------------------------------------------
> -------------
> MY CODE IS:
> ------------
>
> vid = videoinput('winvideo');
>
> preview(vid);
>
> pause;
>
> frame = getsnapshot(vid);
>
> subplot(1,1,1);imshow
(frame,'InitialMagnification','fit');
>
> %save file
> saveas(gca,'TTT.jpeg')
> delete(vid);
>
> closepreview;
>
> -----------------------------------------------
> MATLAB VERSION 7.0.1.24704 (R14) Service Pack 1
> ------------------------------------------------
> Image Axquisition Toolbox 1.7
> -------------------------------------------------

Subject: *HELP* Problem with videoinput, preview statement

From: dpb

Date: 15 Jan, 2008 02:23:42

Message: 4 of 10

Talal Khan wrote:
> OK thanx. so basically your saying i have to update my
> matlab version along with the image acquisition toolbox,
> other wise the PREVIEW wont work. ill try doing that.
> although i think ill have to pay inorder to get the latest
> version. can i not just update it for free or something.
>
...

You can't do much of anything other than patches of current version "for
free or something" from TMW... :)

--

Subject: *HELP* Problem with videoinput, preview statement

From: Talal Khan

Date: 15 Jan, 2008 03:07:01

Message: 5 of 10

dpb <none@non.net> wrote in message
<fmh5nf$q8k$2@aioe.org>...
> Talal Khan wrote:
> > OK thanx. so basically your saying i have to update my
> > matlab version along with the image acquisition
toolbox,
> > other wise the PREVIEW wont work. ill try doing that.
> > although i think ill have to pay inorder to get the
latest
> > version. can i not just update it for free or
something.
> >
> ...
>
> You can't do much of anything other than patches of
current version "for
> free or something" from TMW... :)
>
> --
nice...ill get the new matlab from somewhere as long as
the PREVIEW works on that...btw can u give me some advice
how i should modify my code so that it works when i make
it into an executable. ...you already told me that i have
to use a user defined image handle....then it will work
when its a .exe file.... as in show me the code for it

Talal Khan

Subject: *HELP* Problem with videoinput, preview statement

From: Vihang Patil

Date: 15 Jan, 2008 05:30:20

Message: 6 of 10

Hello
You can try this utility posted in the File Exchange. This
is better than the preview function and can be compiled
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5438&objectType=file

HTH
Vihang

Subject: *HELP* Problem with videoinput, preview statement

From: Dave Tarkowski

Date: 15 Jan, 2008 12:08:19

Message: 7 of 10

Vihang Patil wrote:
> Hello
> You can try this utility posted in the File Exchange. This
> is better than the preview function and can be compiled
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5438&objectType=file
>
> HTH
> Vihang

Vihang,

Thank you, I forgot about that utility. Yes, that utility will allow
you to achieve something similar to the functionality of the PREVIEW
command and will work with the MATLAB Compiler. It lacks some of the
capabilities in the currently shipping version of PREVIEW, but it is an
option in this case.

-Dave Tarkowski

Subject: *HELP* Problem with videoinput, preview statement

From: Dave Tarkowski

Date: 15 Jan, 2008 12:10:20

Message: 8 of 10

Talal Khan wrote:
> dpb <none@non.net> wrote in message
> <fmh5nf$q8k$2@aioe.org>...
>> Talal Khan wrote:
>>> OK thanx. so basically your saying i have to update my
>>> matlab version along with the image acquisition
> toolbox,
>>> other wise the PREVIEW wont work. ill try doing that.
>>> although i think ill have to pay inorder to get the
> latest
>>> version. can i not just update it for free or
> something.
>> ...
>>
>> You can't do much of anything other than patches of
> current version "for
>> free or something" from TMW... :)
>>
>> --
> nice...ill get the new matlab from somewhere as long as
> the PREVIEW works on that...btw can u give me some advice
> how i should modify my code so that it works when i make
> it into an executable. ...you already told me that i have
> to use a user defined image handle....then it will work
> when its a .exe file.... as in show me the code for it
>
> Talal Khan
>

Talal,

The help for PREVIEW in the newer versions of MATLAB has an example of
using an image handle. The code is basically this:

% Create an image object of the same size as your video.
hImage = image(zeros(480,640,3));

% Start the preview.
preview(vid, hImage);

You should also see the reply by Vihang for a utility on MATLAB Central
that will allow you to achieve similar functionality in the version of
MATLAB that you are using.

-Dave

Subject: *HELP* Problem with videoinput, preview statement

From: Talal Khan

Date: 15 Jan, 2008 21:13:02

Message: 9 of 10

ok i downloaded the latest version of matlab including the
toolbox etc. good news and bad news

good news is i managed to get PREVIEW working when i make
an executable by a user defined image handle

The Bad news is i can not get the GETSNAPSHOT to work
outside matlab enivironment...i.e when i make an
executable...any solution to that??


Dave Tarkowski <dave.tarkowski@mathworks.com> wrote in
message <fmi7rc$4pe$2@fred.mathworks.com>...
> Talal Khan wrote:
> > dpb <none@non.net> wrote in message
> > <fmh5nf$q8k$2@aioe.org>...
> >> Talal Khan wrote:
> >>> OK thanx. so basically your saying i have to update
my
> >>> matlab version along with the image acquisition
> > toolbox,
> >>> other wise the PREVIEW wont work. ill try doing
that.
> >>> although i think ill have to pay inorder to get the
> > latest
> >>> version. can i not just update it for free or
> > something.
> >> ...
> >>
> >> You can't do much of anything other than patches of
> > current version "for
> >> free or something" from TMW... :)
> >>
> >> --
> > nice...ill get the new matlab from somewhere as long
as
> > the PREVIEW works on that...btw can u give me some
advice
> > how i should modify my code so that it works when i
make
> > it into an executable. ...you already told me that i
have
> > to use a user defined image handle....then it will
work
> > when its a .exe file.... as in show me the code for it
> >
> > Talal Khan
> >
>
> Talal,
>
> The help for PREVIEW in the newer versions of MATLAB has
an example of
> using an image handle. The code is basically this:
>
> % Create an image object of the same size as your video.
> hImage = image(zeros(480,640,3));
>
> % Start the preview.
> preview(vid, hImage);
>
> You should also see the reply by Vihang for a utility on
MATLAB Central
> that will allow you to achieve similar functionality in
the version of
> MATLAB that you are using.
>
> -Dave

Subject: *HELP* Problem with videoinput, preview statement

From: Talal Khan

Date: 15 Jan, 2008 23:19:02

Message: 10 of 10

hey guys iv resolved the problem... the problem wasnt in
the getsnapshot, it was in the 'pause' i used... thanx
for everything u guys helped allot....:)

"Talal Khan" <talaltk@mathwork.com> wrote in message
<fmj7ku$ilf$1@fred.mathworks.com>...
> ok i downloaded the latest version of matlab including
the
> toolbox etc. good news and bad news
>
> good news is i managed to get PREVIEW working when i
make
> an executable by a user defined image handle
>
> The Bad news is i can not get the GETSNAPSHOT to work
> outside matlab enivironment...i.e when i make an
> executable...any solution to that??
>
>
> Dave Tarkowski <dave.tarkowski@mathworks.com> wrote in
> message <fmi7rc$4pe$2@fred.mathworks.com>...
> > Talal Khan wrote:
> > > dpb <none@non.net> wrote in message
> > > <fmh5nf$q8k$2@aioe.org>...
> > >> Talal Khan wrote:
> > >>> OK thanx. so basically your saying i have to
update
> my
> > >>> matlab version along with the image acquisition
> > > toolbox,
> > >>> other wise the PREVIEW wont work. ill try doing
> that.
> > >>> although i think ill have to pay inorder to get
the
> > > latest
> > >>> version. can i not just update it for free or
> > > something.
> > >> ...
> > >>
> > >> You can't do much of anything other than patches of
> > > current version "for
> > >> free or something" from TMW... :)
> > >>
> > >> --
> > > nice...ill get the new matlab from somewhere as long
> as
> > > the PREVIEW works on that...btw can u give me some
> advice
> > > how i should modify my code so that it works when i
> make
> > > it into an executable. ...you already told me that i
> have
> > > to use a user defined image handle....then it will
> work
> > > when its a .exe file.... as in show me the code for
it
> > >
> > > Talal Khan
> > >
> >
> > Talal,
> >
> > The help for PREVIEW in the newer versions of MATLAB
has
> an example of
> > using an image handle. The code is basically this:
> >
> > % Create an image object of the same size as your
video.
> > hImage = image(zeros(480,640,3));
> >
> > % Start the preview.
> > preview(vid, hImage);
> >
> > You should also see the reply by Vihang for a utility
on
> MATLAB Central
> > that will allow you to achieve similar functionality
in
> the version of
> > MATLAB that you are using.
> >
> > -Dave
>

Tags for this Thread

No tags are associated with this thread.

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.

Contact us