March 9, 2010

Using Webcam in MATLAB for Image Acquisition

Wanted to access webcam via MATLAB, read this.

In MATLAB, you can check if the support is available for your  camera. MATLAB has built-in adaptors for accessing these devices.

You must check if you have the data acquisition toolbox in your version. that you have installed.
Just get to the MATLAB Start menu > Toolboxes > Data Acquisition


To get information about installed adapters, type
>> imaqhwinfo
Here, in this case the adaptor is 'winvideo'
To get more information about the device, type
>> info=imaqhwinfo('winvideo')


 Now let's see how to use the webcam
1) Connect your webcam to the computer through the USB, or use the intergrated laptop camera.
You can preview the video captured by the image by defining an object and associate it with the device.
>> vid = videoinput('winvideo', 1, 'RGB24_320×240');




2) Open Preview window to view video in realtime
>> preview(vid);

3) Capturing and storing images

1. Capturing an image
To capture an image from the video, define the object vid as described before and use getdata to capture a frame from the video.
>>start(vid); 
>>im=getdata(vid,1);  % im = getsnapshot(vid); alternative use
>>figure,imshow(im);

2. Storing the image
You can store the captured image as a .jpg or .gif file using imwrite function. 
>>imwrite(im,'myfirstimage.jpg');

This image will be stored in current work directory folder. 

Now try yourself, add, and tweak.

6 comments:

Anonymous,  May 31, 2013  

As lengthy as we have Chuck Norris, China will surely fail.


Here is my weblog: 2 girls teach sex Review

Anonymous,  June 13, 2013  

Would you mind if I publish your recipe on Mark's Daily Apple being a full blog publish?

My web page ... healthy cooking oils foods

Anonymous,  June 14, 2013  

I coupon. But not so incredibly. I only clip for what I'd get anyhow. Of course, at times that's processed, but my whole
cart is not loaded up with it. And each and every as soon as
in a even though I am capable to seek out a coupon to the healthier
stuff I purchase each trip in any case. It saves time
although clipping and pressure in the store. Cost-free will not usually equivalent great.


my web-site ... why eat healthy food

impotence November 25, 2020  

Great website. Lots of helpful information here. I am sending it to a few friends ans also sharing in delicious. And certainly, thank you on your effort!

top erection pills November 25, 2020  

I'm really enjoying the theme/design of your website. Do you ever run into any web browser compatibility problems? A number of my blog visitors have complained about my website not working correctly in Explorer but looks great in Opera. Do you have any suggestions to help fix this issue?

erectile dysfunction November 25, 2020  

I like what you guys tend to be up too. This kind of clever work and exposure! Keep up the fantastic works guys I've included you guys to blogroll.

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP