Introduction
I was working for a project to develop a web conferencing application. I accepted
the project and started to work on it. My first effort was to integrate a web cam into my application. I searched
about it and found that it’s very simple. I
have been very busy doing this project. Here is my first and small effort which makes my mind clear
about the completion of this project.
Requirements
- Latest Flash player
- Web camera
The solution
You need to:
- Copy the “WebcamResources” into your new application.
- Add the following code in to your Default.aspx page:
<object width="450" height="200"
param name="movie1" value="WebcamResources/save_picture.swf"
embed src="WebcamResources/save_picture.swf" width="450"
height="200" >
</object>
This code will place your Flash object into your web page, used to capture
the images from the web cam.
- Add one more page there with the name ImageConversions.aspx.
- Add the following code into ImageConversion.aspx at the page load event:
string str_Photo = Request.Form["image_Data"];
byte[] photo = Convert.FromBase64String(str_Photo);
FileStream f_s = new FileStream("C:\\capture.jpg", FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter b_r = new BinaryWriter(f_s);
b_r.Write(photo);
b_r.Flush();
b_r.Close();
f_s.Close();
The above code will convert the bytes to an image and will save the image in
the c drive.
Enjoy!