找不到类型或命名空间名称'WebCam_Capture'(您是否缺少using指令或程序集引用?) [英] The type or namespace name 'WebCam_Capture' could not be found (are you missing a using directive or an assembly reference?)

查看:278
本文介绍了找不到类型或命名空间名称'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() ;
}
}
}

解决方案

检查项目的配置文件是什么。 />


它可能是.Net Framework 4 Client Profile



将其更改为.Net Framework 4和构建


我也遇到了同样的问题。你需要包含在你获得此代码的同一网站上提供的dll文件。



您将从
获得dll文件


https://sites.google.com/site/webcamlibrarydotnet/wpf-and-csharp-sample - 代码和下载



下载后

visual studio - > project->添加现有项目> dll文件

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();
        }
    }
}

解决方案

Check what was the profile for the project.

It might be ".Net Framework 4 Client Profile"

change it to ".Net Framework 4" and build


I also faced the same issue.You need to include the dll file that is available in the same website where you got this code.

You will get the dll file from

https://sites.google.com/site/webcamlibrarydotnet/wpf-and-csharp-sample-code-and-download

After downloading
visual studio-->project->add existing item->dll file


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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆