John Luciani

John Luciani

  • NA
  • 23
  • 17.6k

C# WebCam with .dll wrapper

Apr 19 2012 3:29 PM
I am trying to integrate a webcam into a fitness tracking program I have made for persons with disabilities, specifically down syndrome.  I need to make it as simple as possible for someone to come up, select take a picture and the form pops up, etc...

Below is the code I am using to implement the wrapper found in this article: http://www.c-sharpcorner.com/uploadfile/yougerthen/integrate-the-web-webcam-functionality-using-C-Sharp-net-and-com-part-viii/

I have implemented as stated.  The program will run but my buttons do not do anything when clicked.  Am I missing something?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WebCamera;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = null;
        }
            private void Form1_Load(object sender, EventArgs e)
            {
                oWebCam = new WebCamera.WebCam();
                oWebCam.Container = pictureBox1;
            }
            WebCam oWebCam;
            private void btnStart_Click(object sender, EventArgs e)
            {
                oWebCam.OpenConnection();
            }

            private void btnSave_Click(object sender, EventArgs e)
            {
                oWebCam.SaveImage();
            }

            private void btnStop_Click(object sender, EventArgs e)
            {
                oWebCam.Dispose();
            }

            private void Form1_Load_1(object sender, EventArgs e)
            {

            }

            private void btnStart_Enter(object sender, EventArgs e)
            {
                Button b = (Button)sender;
                b.BackColor = Color.Red;
            }

            private void btnStart_Leave(object sender, EventArgs e)
            {
                Button b = (Button)sender;
                b.BackColor = Color.Gray;
            }

            }
}

Else Everything is the same as the above example.  The form loads but the buttons do not do anything.

Answers (4)