【问题标题】:Capture am image from webcam and save从网络摄像头捕获图像并保存
【发布时间】:2013-03-17 21:19:03
【问题描述】:

大家好,我正在尝试保存从我的网络摄像头拍摄的照片。 我实际上正在使用此代码

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)
        {

        }
    }
}

应用程序运行,我看到图像,我单击捕获按钮,直到这里它没有给出错误但是但是......没有图像被保存我从下载样本 这里:http://www.dotnetspider.com/resources/38150-Capture-save-images-from-Web-camera.aspx(查看附件)

【问题讨论】:

  • 你遇到了什么错误?
  • @Emmanuel N 没有错误,伙计....它运行良好但我无法获得应保存在 C:\\Webcam.jpg 的图像
  • 哦,伙计们,我得到了解决方案:\你只是不把它保存在驱动器 C 上:更改保存路径,我会很好 @Emmanuel N thks fr ur 关注兄弟。

标签: asp.net image save webcam


【解决方案1】:

试试这篇文章。它工作得很好。但是当未连接网络摄像头时,我无法使用自定义消息。它给出了一个自动生成的错误消息。

webcamlibrarydotnet

【讨论】:

    【解决方案2】:

    更改路径..我也有同样的问题.. 您的 C 盘安全级别高, 将路径更改为“D:\Webcam.jpg”,它将起作用

    【讨论】:

      猜你喜欢
      • 2013-06-03
      • 2013-02-09
      • 1970-01-01
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多