المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Take picture from Webcam (problem)



C# Programming
06-15-2009, 08:04 AM
Curently i take a picture from webcam and load into the picture box by this way. take picture and save in to hard disk and load it again into picture box. is there any easy way to do this?

try
{
DeviceManager manager = new DeviceManagerClass();
Device d = null;
foreach (DeviceInfo info in manager.DeviceInfos)
{
d = info.Connect();
}
int i = 0;
Item item = d.ExecuteCommand(CommandID.wiaCommandTakePicture);
foreach (string format in item.Formats)
{
WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
imagefile.SaveFile("d:\\" + i + ".jpeg");
pictureBox1.Image = Image.FromFile("d:\\" + i + ".jpeg");
i++;

A S E L A