Got Questions? Get Answers.
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:
Webcam in matlab gui

Subject: Webcam in matlab gui

From: Sprinceana

Date: 20 Jul, 2009 07:00:02

Message: 1 of 9

I'm using guide tool in matlab and I want to integrate a webcam in matlab for image acquisition.

My question is:

How can I integrate a webcam in matlab gui that tracks and makes image acquisition?



I know that I must have installed Data Acquisition Toolbox , I have it I read this article on this blog but I cannot figure out what I must do to my gui to integrate a webcam in matlab gui.

To list all functions of Data Acquisition Toolbox I use in command window (I discovered myself that):


>>help daq % to list all functions from Data Acquisition Toolbox

But I don't know what functions I must use to achieve the thing I want.

Any ideas?


Here's the helpful link I found:

http://madan.wordpress.com/2007/03/23/image-capture-using-webcam-in-matlab/


This thing I write in A pushbutton of a gui (the named of the button is called connect to webcam to activate the webcam?)

Notice that the adaptor is ‘Winvideo’

Any webcam you connect is accessed through this adaptor. Now the main part
1)Connect your webcam to the computer through the USB.
vid = videoinput(’winvideo’, 1, ‘RGB24_320?240′);

Specify the adaptor name and resolution

2) Open Preview window to view video at runtime
preview(vid);

This will open a window similar to yahoo messenger Webcam interface. And you will be able to view the video demo the webcam at runtime

3) Capture
data = getsnapshot(vid);

Any helpful ideas would be really appreciated!

Also another helpful link I found is this:

http://www.edaboard.com/ftopic325427.html

I found also this thing on FEX but I wanted to use Data Acquisition toolbox presented in madan.wordpress.com

http://www.mathworks.com/matlabcentral/fileexchange/22792

Subject: Webcam in matlab gui

From: Sprinceana

Date: 20 Jul, 2009 07:09:01

Message: 2 of 9

>> imaqhwinfo

ans =

    InstalledAdaptors: {'winvideo'}
        MATLABVersion: '7.1 (R14SP3)'
          ToolboxName: 'Image Acquisition Toolbox'
       ToolboxVersion: '1.9 (R14SP3)'

>>


This is how appear to me I have installed the adaptor winvideo.


I don't understand then the next steps of code....I must integrate them in a pushbutton of gui?

Can you help me pls?

Subject: Webcam in matlab gui

From: Sprinceana

Date: 20 Jul, 2009 07:12:01

Message: 3 of 9

I found other links here but I don't understand the steps from madan the last steps.

http://www.lmgtfy.com/?q=Image+capture+using+webcam+in+matlab

Subject: Webcam in matlab gui

From: Mark Jones

Date: 23 Jul, 2009 13:19:37

Message: 4 of 9

Sprinceana wrote:
> I found other links here but I don't understand the steps from madan the last steps.
>
> http://www.lmgtfy.com/?q=Image+capture+using+webcam+in+matlab

Hi,

Which steps are giving you trouble?

Also, have you taken a look at:

http://www.mathworks.com/access/helpdesk/help/toolbox/imaq/exampleindex.html

and:

http://www.mathworks.com/access/helpdesk/help/toolbox/imaq/f11-74309.html#f11-76067

Mark

Subject: Webcam in matlab gui

From: Sprinceana

Date: 29 Jul, 2009 10:19:02

Message: 5 of 9

Hi mark!

Hi for quick reply!

I want to integrate a webcam in my matlab gui that makes image acquisition

I have a pushbutton called Integrate webcam.

When I press the pushbutton I want that matlab make image acquisition.

I have a laptop ASUS F5RL with webcam integrated.

So my question is how I can integrate the webcam towards matlab?

Here's what I've tried in pushbutton named Integrate Webcam:


Thank you also for your links!


integrate_webcam.m contains:

function pushbutton1_callback contains:

% I have a webcam integrated on my pc via usb


Here's my webcam integrated:

http://img252.imageshack.us/img252/9974/webcamviausb.png

When I click usb webcam it activates my webcam which has 1.3 megapixels.

%connect webcam via usb

vid = videoinput(’winvideo’, 1, ‘RGB24_320?240′);

Specify the adaptor name and resolution

% Open Preview window to view video at runtime
preview(vid);

%This will open a window similar to yahoo messenger Webcam interface. And you will be able to view the video demo the webcam at runtime

%Capture
data = getsnapshot(vid);

Here's the full source attached here what I've tried so far:

http://www.flyupload.com/?fid=357534156

or here:

http://www.easy-share.com/1907011044/integrate_web

Subject: Webcam in matlab gui

From: Dave Brackett

Date: 29 Jul, 2009 22:50:18

Message: 6 of 9

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h4p7mm$qo6$1@fred.mathworks.com>...
> Hi mark!
>
> Hi for quick reply!
>
> I want to integrate a webcam in my matlab gui that makes image acquisition
>
> I have a pushbutton called Integrate webcam.
>
> When I press the pushbutton I want that matlab make image acquisition.
>
> I have a laptop ASUS F5RL with webcam integrated.
>
> So my question is how I can integrate the webcam towards matlab?
>
> Here's what I've tried in pushbutton named Integrate Webcam:
>
>
> Thank you also for your links!
>
>
> integrate_webcam.m contains:
>
> function pushbutton1_callback contains:
>
> % I have a webcam integrated on my pc via usb
>
>
> Here's my webcam integrated:
>
> http://img252.imageshack.us/img252/9974/webcamviausb.png
>
> When I click usb webcam it activates my webcam which has 1.3 megapixels.
>
> %connect webcam via usb
>
> vid = videoinput(’winvideo’, 1, ‘RGB24_320?240′);
>
> Specify the adaptor name and resolution
>
> % Open Preview window to view video at runtime
> preview(vid);
>
> %This will open a window similar to yahoo messenger Webcam interface. And you will be able to view the video demo the webcam at runtime
>
> %Capture
> data = getsnapshot(vid);
>
> Here's the full source attached here what I've tried so far:
>
> http://www.flyupload.com/?fid=357534156
>
> or here:
>
> http://www.easy-share.com/1907011044/integrate_web


This is the most relevant exerpt from the second hyperlink mark supplied:

Previewing Data in Custom GUIs
Instead of using the toolbox's Video Preview window, you can use the preview function to direct the live video stream to any Handle Graphics image object. In this way, you can incorporate the toolbox's previewing capability in a GUI of your own creation. (You can also perform custom processing as the live video is displayed. For information, see Performing Custom Processing of Previewed Data.)

To use this capability, create an image object and then call the preview function, specifying a handle to the image object as an argument. The preview function outputs the live video stream to the image object you specify.

The following example creates a figure window and then creates an image object in the figure, the same size as the video frames. The example then calls the preview function, specifying a handle to the image object.

% Create a video input object.
vid = videoinput('winvideo');

% Create a figure window. This example turns off the default
% toolbar, menubar, and figure numbering.

figure('Toolbar','none',...
       'Menubar', 'none',...
       'NumberTitle','Off',...
       'Name','My Preview Window');

% Create the image object in which you want to display
% the video preview data. Make the size of the image
% object match the dimensions of the video frames.

vidRes = get(vid, 'VideoResolution');
nBands = get(vid, 'NumberOfBands');
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );

% Display the video data in your GUI.

preview(vid, hImage);

Subject: Webcam in matlab gui

From: Sprinceana

Date: 30 Jul, 2009 06:38:02

Message: 7 of 9

Thank you very much!


This thing must be integrated in my pushbutton1_callback?


Or I made another one?

I'm using matlab guide tool .

Subject: Webcam in matlab gui

From: Dave Brackett

Date: 30 Jul, 2009 08:19:01

Message: 8 of 9

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h4rf4a$1b9$1@fred.mathworks.com>...
> Thank you very much!
>
>
> This thing must be integrated in my pushbutton1_callback?
>
>
> Or I made another one?
>
> I'm using matlab guide tool .

It can be in whichever callback you want to initiate the action, e.g. a pushbutton.

Subject: Webcam in matlab gui

From: Sprinceana

Date: 30 Jul, 2009 16:08:01

Message: 9 of 9

"Dave Brackett" <davebrackett@hotmail.com> wrote in message <h4rl1l$ldn$1@fred.mathworks.com>...
> "Sprinceana " <mihaispr@yahoo.com> wrote in message <h4rf4a$1b9$1@fred.mathworks.com>...
> > Thank you very much!
> >
> >
> > This thing must be integrated in my pushbutton1_callback?
> >
> >
> > Or I made another one?
> >
> > I'm using matlab guide tool .
>
> It can be in whichever callback you want to initiate the action, e.g. a pushbutton.


Ok. Thank you very much!

Tags for 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