Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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?)'


C#
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


C#
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();
        }
    }
}
Posted
Updated 29-Jan-13 20:27pm
v2

Check what was the profile for the project.

It might be ".Net Framework 4 Client Profile"

change it to ".Net Framework 4" and build
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900