Saturday, 14 June 2014

How to acquire video from matlab in real time and convert to frames

To get the information about devices

info=imaqhwinfo
info.InstalledAdaptors
info = imaqhwinfo('winvideo')
dev_info = imaqhwinfo('winvideo', 1)
info.DeviceInfo
info.DeviceInfo.SupportedFormats
%celldisp(dev_info.SupportedFormats);
imaqtool
How to acquire video from matlab in real time

vid=videoinput('winvideo',1);
preview(vid);
start(vid);
% foto=getsnapshot(vid);
%image(foto);
im=getdata(vid,1);figure,imshow(im);
imwrite(im,'testimage.jpg');


  • imaqhwinfo gives information about the existing adaptors for your webcam device
  • winvideo is one of the adaptors.
  • Further information pertaining to the device can be obtained by imaqhwinfo('winvideo',1) where 1 is the Device ID you saw earlier
  • The resolution (800×600, 1024×768, 1600×1200, etc.), format (RGB, YUV, etc.) which needs to be selected when creating a video object.
  • create a videoinput object
    ->vidobj = videoinput('winvideo',1,'RGB_1024x768');
  • to start your video object start(vidobj)
  • You can obtain snapshots of capture by using the frame = getsnapshot(vidobj)
  • view the continuous stream of frames by saying preview(vidobj);
  • A stop(vidobj) followed by delete(vidobj) is the best way to follow.
  • All the options can be seen by imaqhelp(videoinput).

No comments:

Post a Comment