Search This Blog

Monday, April 9, 2012

GUI codes for Campture image using webcam - Matlab

Today i will tell you how to capture image using webcam in GUI using matlab

before go to GUI, we have have to know that how to connect webcam to MATLAB for that go to how to connect webcam to MATLAB click here

Than create Push button on GUI which is used to capture images

Click Start -> Matlab -> GUIDE(GUI Builder)


Select Blank GUI(default) -> press ok


Select push button and draw push button as show in fig


Go to the inspector and change string to start


Now save GUI

After saving GUI Editor window will open

write below codes under puchbutton1_callback function as shown in fig below

close all;
clear all;
clc;
%to close preview window
closepreview
%winvideo is webcam port address
%use your webcam port address
vid=videoinput('winvideo');
%to open preview window
preview(vid)
%press enter to capture image
pause
%to capture image
data = getsnapshot(vid);
delete(vid)
%to display capture image
figure
imshow(data)


Now save editor window and run .fig file and click start button
preview will open than click enter to capture images

Note :- It work only matlab 9 and above matlab version

if you get any error let me know from your comment and don`t forget to tell thanks

Related Posts :-
how to run m file in gui using matlab
Matlab code for shutdown computer
How to see webcam preview in Matlab
How to capture image form webcam in Matlab
How to connect microsoft access to Matlab
How to install matlab 2007 on Windows7
How to connect Mysql to Matlab
How to use Nimbuzz chat room in PC

7 comments:

  1. thanks thats a wonderfull tutorial!!!

    ReplyDelete
  2. i am very thankful to you sir ...n i have a small problem with my code for concealed weapon detection using image fusion....can u please rectify it.....

    ReplyDelete
  3. thanks so lot for guiding us...n i have a small query regarding the code concealed weapon detection using image fusion in GUI ..can u plz rectify it

    ReplyDelete
    Replies
    1. Ya Sure, Mail Your source code to contact@aboutcodes.com

      Delete
  4. Thank you sir bt I get one error...I am not able to see available adapters name..

    ReplyDelete
  5. sir can you please tell me how to do the same for image capturing by button

    ReplyDelete