本文介绍了找不到类型或命名空间名称'WebCam_Capture'(您是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码拍摄照片。并且面临问题

'找不到类型或命名空间名称'WebCam_Capture'(您是否缺少using指令或汇编引用?)'





 使用系统; 
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Text;
使用 System.Windows.Forms;
使用 System.IO;
使用 WinFormCharpWebCam;
命名空间 Camera_Sample
{
public partial class Form1:Form
{
WebCam webcam; // 为处理从Webcamera捕获图像的任务而创建的自定义类
public Form1()
{
InitializeComponent();
}

private void Form1_Load( object sender,EventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam( ref imgCam);
}

private void btnStart_Click( object sender,EventArgs e)
{
webcam.Start();
}

private void btnStop_Click( object sender,EventArgs e)
{
webcam.Stop();
}

private void imgPreview_Click( object sender,EventArgs e)
{

}

private void btnContinue_Click( object sender,EventArgs e)
{
webcam。继续();
}

private void btnClick_Click( object sender,EventArgs e)
{
imgPreview.Image = imgCam.Image;
}

private void btnSave_Click( object sender,EventArgs e)
{
SaveFileDialog sdialog = new SaveFileDialog();
sdialog.FileName = 图像; // 默认文件名
sdialog.DefaultExt = 。jpg; // 默认文件扩展名
sdialog.Filter = 图像(.jpg)| * .jpg; // 按扩展名过滤文件

// 显示保存文件对话框
// 处理保存文件对话框结果
如果(sdialog.ShowDialog()== DialogResult.OK)
{
// 保存图片
string filename = sdialog.FileName;
FileStream fstream = new FileStream(filename,FileMode.Create);
imgPreview.Image.Save(fstream,System.Drawing.Imaging.ImageFormat.Jpeg);
fstream.Close();
}
}
}
}











WebCam.cs摄像头课程





 使用系统; 
使用 System.IO;
使用 System.Text;
使用 WebCam_Capture;
使用 System.Collections.Generic;



namespace CSharpWebCam
{
// 设计者Dharma Iyer
class WebCam
{
私人 WebCamCapture网络摄像头;
private System.Windows.Forms.PictureBox _FrameImage;
private int FrameNumber = 30 ;
public void InitializeWebCam( ref System.Windows.Forms.PictureBox ImageControl)
{
webcam = new WebCamCapture();
webcam.FrameNumber =(( ulong )(0ul));
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.ImageCaptured + = new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;
}

void webcam_ImageCaptured( object source,WebcamEventArgs e)
{
_FrameImage.Image = e.WebCamImage;
}

public void Start()
{
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.Start( 0 );
}

public void Stop()
{
webcam.Stop();
}

public void 继续()
{
// 更改捕获时间范围
webcam.TimeToCapture_milliseconds = FrameNumber;

// 从停止恢复视频捕获
网络摄像头.Start( this .webcam.FrameNumber);
}

public void ResolutionSetting()
{
webcam.Config();
}

public void AdvanceSetting()
{
webcam.Config2();
}


内部 void InitializeWebCam(系统.Windows.Forms.PictureBox imgCam)
{
throw new NotImplementedException() ;
}
}
}
解决方案



i am using following Code for taking image. and facing the problem
'The type or namespace name 'WebCam_Capture' could not be found (are you missing a using directive or an assembly reference?)'


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using WinFormCharpWebCam;
namespace Camera_Sample
{
    public partial class Form1 : Form
    {
        WebCam webcam; //customized class created for handling the task of capturing image from Webcamera
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            webcam = new WebCam();
            webcam.InitializeWebCam(ref imgCam);
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            webcam.Start();
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            webcam.Stop();
        }

        private void imgPreview_Click(object sender, EventArgs e)
        {

        }

        private void btnContinue_Click(object sender, EventArgs e)
        {
            webcam.Continue();
        }

        private void btnClick_Click(object sender, EventArgs e)
        {
            imgPreview.Image = imgCam.Image;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sdialog = new SaveFileDialog();
            sdialog.FileName = "Image";// Default file name
            sdialog.DefaultExt = ".Jpg";// Default file extension
            sdialog.Filter = "Image (.jpg)|*.jpg"; // Filter files by extension

            // Show save file dialog box
            // Process save file dialog box results
            if (sdialog.ShowDialog() == DialogResult.OK)
            {
                // Save Image
                string filename = sdialog.FileName;
                FileStream fstream = new FileStream(filename, FileMode.Create);
                imgPreview.Image.Save(fstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                fstream.Close();
            }
        }
    }
}






WebCam.cs Class for webcam


using System;
using System.IO;
using System.Text;
using WebCam_Capture;
using System.Collections.Generic;



namespace CSharpWebCam
{
    //Design by Dharma Iyer
    class WebCam
    {
        private WebCamCapture webcam;
        private System.Windows.Forms.PictureBox _FrameImage;
        private int FrameNumber = 30;
        public void InitializeWebCam(ref System.Windows.Forms.PictureBox ImageControl)
        {
            webcam = new WebCamCapture();
            webcam.FrameNumber = ((ulong)(0ul));
            webcam.TimeToCapture_milliseconds = FrameNumber;
            webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
            _FrameImage = ImageControl;
        }

        void webcam_ImageCaptured(object source, WebcamEventArgs e)
        {
            _FrameImage.Image = e.WebCamImage;
        }

        public void Start()
        {
            webcam.TimeToCapture_milliseconds = FrameNumber;
            webcam.Start(0);
        }

        public void Stop()
        {
            webcam.Stop();
        }

        public void Continue()
        {
            // change the capture time frame
            webcam.TimeToCapture_milliseconds = FrameNumber;

            // resume the video capture from the stop
            webcam.Start(this.webcam.FrameNumber);
        }

        public void ResolutionSetting()
        {
            webcam.Config();
        }

        public void AdvanceSetting()
        {
            webcam.Config2();
        }


        internal void InitializeWebCam(System.Windows.Forms.PictureBox imgCam)
        {
            throw new NotImplementedException();
        }
    }
}
解决方案



这篇关于找不到类型或命名空间名称'WebCam_Capture'(您是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 02:44
查看更多