当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - Capture am image from webcam and save

问题描述:

Hello guys im trying to save a picture taken from my webcam.

im actually using this code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.IO;

public partial class ImageConversions : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

CreatePhoto();

}

void CreatePhoto()

{

try

{

string strPhoto = Request.Form["imageData"]; //Get the image from flash file

byte[] photo = Convert.FromBase64String(strPhoto);

FileStream fs = new FileStream("C:\\Webcam.jpg", FileMode.OpenOrCreate, FileAccess.Write);

BinaryWriter br = new BinaryWriter(fs);

br.Write(photo);

br.Flush();

br.Close();

fs.Close();

}

catch (Exception Ex)

{

}

}

}

The application RUNS, i get to see the image , i click the capture button it gives no error till here BUT BUT BUT ... NO IMAGE IS SAVED EITHER i downloaded the sample from

HERE : http://www.dotnetspider.com/resources/38150-Capture-save-images-from-Web-camera.aspx (check the attachemnt)

网友答案:

try this artical. it works pretty good. But i couldnt work with a custom message when webcam is not attached. it gives a auto generated error message

https://sites.google.com/site/webcamlibrarydotnet/winfrom-and-csharp-sample-code-and-download
网友答案:

Change Path.. I also had same problem.. Your C Drive Has security level high, Change path to "D:\Webcam.jpg" and it will work

分享给朋友:
您可能感兴趣的文章:
随机阅读: