Friday 15 June 2012
On 07:41 by Unknown in matlab tutorial No comments
Here in this post I discuss
about how to connect MATLAB? And taking images from Webcam?
So first of all we
need a videobject of the webcam video. Here
“obj =
videoinput('winvideo',1)” create the videoobject. The description of this line is discussed
next.
The winvideo is a video
adapter for webcam. And videoinput creates an object of webcam through winvideo
adapter, & save it in obj variable. One another thing is the definition of
webcam. It is possible that one have more than one webcams. Since the sequence
number of webcam defines which webcam you want to connect. 1 is for internal system webcam or 1st
webcam. If someone has two webcam & want to connect the 2nd
webcam to MATLAB then it will be 2.
After creation the
videoobject now I call this object and run the live video through “preview (obj)” command. We have
live video, now Images can take easily from this video, “getsapshot(obj)” function is used for this purpose. We can
easily convert this image frame to grayscale image through function “rgb2gray(frame)”. At almost all cases the same size images
needed for further procession, since the images are resized to 64 by 64 size.
64 by 64 is so small size, you can resize it to 128 by 128, 320 by 440 etc,
this process is done through “imresize(file_name,[128,
128])”. We can show this image
by “imshow(frame)” function.
But only the first image will show.
We can also save this image
to the system directory through “imwrite(file-name,
directory, extention-type-of-image)” function. In the code “int2str(k)” is used to convert
the integer value of k to string type, to save it in a directory.
Loop while defines the number
of images one can want to take from video. it will be decide by environment and
the purposes where the program is used. Here I take 5 images from this video
which is done through the highest value of k, “if (k==4)”. Now I pause the first image to the screen to
show first image, close the image, & then delete the videoobject, to save
memory.
%% Create a video object to the webcame of system.
obj = videoinput('winvideo',1);
preview(obj);
k = 0;
while(true)
frame =
getsnapshot(obj);
frame=rgb2gray(frame);
% Resize Image Size to desired size. I resized it to 64 by 64
frame=imresize(frame,
[64 64]);
imshow(frame);
k = k+1;
% Save the
Images to a directory
imwrite(frame,'F:\ImageProcessing\studymaterial\PROJECT\OurProjet\Detection_Queue\image' , int2str(k),'.jpeg']);
% k defines number of Images take from video,I take
5 Images.
if(k==4)
break;
end
end
%% This will remove the video object permanently
% pause will still the image on the screen
pause(1);
% This will remove the showing image from memory
close;
% This will permanently delete the video object from memory
delete(obj);
Live Video Stream |
First Image Captured from video |
All 4 Images Taking from Video |
Subscribe to:
Post Comments (Atom)
Search
Popular Posts
-
Here in this post I discuss about how to connect MATLAB? And taking images from Webcam? So first of all we need a videobject of the web...
-
Erlang B table is attached in this post with up to 115 number of channels, and more GOS probability values. This will help you to solve Erl...
-
Erlang C table is attached in this post with up to 45 number of channels, and more GOS probability values. This will help you to solve Erla...
-
Example Mini-AES Encryption The application of the four components NibbleSub , ShiftRow , MixColumn and KeyAddition in sequence con...
-
Mini Advanced Encryption Standard (Mini-AES): A Testbed for Cryptanalysis Students Raphael Chung-Wei Phan ADDRESS: Swin...
-
Programming Methodologies Two popular approaches to programming design are the structured approach and the object-oriented approach, whi...
-
Telecommunication & Networking is the emerging technologies now a days. In fast these both fields are distinguish from each other. Tel...
-
Basic to MATLAB Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environmen...
-
Solution of DATA & Network Security Mid Term Paper Data & Network Security. ...
-
Matlab Basic Part 2 In the first Part We See Some Basic of Matlab. now in the Part 2we will see some advanced functions and methods of...
Categories
- Advanced Wireless Networks (26)
- Wireless Networks (21)
- Data and Network Security (20)
- Digital Logic Design (7)
- matlab tutorial (5)
- C Programing (3)
- Research Papers (2)
Editorial
- Javed Chaudhry (21)
- PANAMA Leaks (18)
- Wasat Ullah Khan (11)
- Abdul Qadir Hassan (10)
- PAK-America Relationship (7)
- Ali Ahmad Dhalo (6)
- Muqtada Mansoor (6)
- Asghar Abdullah (4)
- Dr. Abdul Qadeer Khan (4)
- PAK-India Relationship (4)
- Aftab Iqbal (2)
- Ayaz Ameer (2)
- Doctor Atta Ur Rehman (2)
- PAK-Afghan Relationship (2)
- PAK-Chaina Relationship (2)
- PAK-Iran Relationship (2)
- Anees Baqir (1)
Sample Text
Blog Archive
My Traffic
Powered by Blogger.
0 comments:
Post a Comment