Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi!

I am trying to set up an IR-securitycam with C# Express 2010. I have made a layout on C# and downloaded all the AForge libraries I need. The securitycam is using USB to communicate with the computer:

[^]

I have used this source code which I found on the internet:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenCVDotNet;                 //add here

namespace Webcam1
{
    public partial class Form1 : Form
    {
        private CVCapture capture;  //variable here
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            capture = new CVCapture(0); //0 means current webcam attaced
        }
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = !(timer1.Enabled); // toggle start/stop
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            using (CVImage nextFrame = capture.QueryFrame())
            {
                pictureBox1.Image = nextFrame.ToBitmap();
            }
        }
    }
}


When I try to assemble the program, I get two identical errors: "The name ´Timer 1´does not excist". I would really appreciate some help on how to debug this error.

Regards
Sandy
Posted
Updated 16-Aug-11 1:20am
v4

1 solution

Well there are 2 timer1 references in your code;
C#
timer1.Enabled = !(timer1.Enabled); 

but do not see any reference to the timer acutally being created.

If you do not use a timer, bin the code and the timer tick method or comment it out at the moment.

If you need a timer then add one;
C#
Timer timer1 = new Timer();
 
Share this answer
 
Comments
sandy6 16-Aug-11 8:38am    
Great! Thank you very much DaveAuld!

The errors disappeared when i commented the orders out. I though experienced a new error:

"The type or namespace name ´Form1´ could not be found. (are you missing a using directive or an assembly reference?)" Do you know how I can fix this error too?

Sandy
DaveAuld 16-Aug-11 9:42am    
Its the same sort of thing, there is a reference to Form1 somewhere that can't find Form1. This is the danger when copy and paste borrowed code, rather than understanding what is going on and making sure you are only taking what you really need.
sandy6 30-Aug-11 7:30am    
okay, now i have debugged and builded the project and the designed window pops up as it should. When i push the refresh button while the USB camera is connected,it is written in the combobox "USB 2.0 grabber". When i then push the start button nothing happens. Can somebody help me/explain to me what is wrong?
DaveAuld 30-Aug-11 7:38am    
Sandy, i would suggest you post a new question, complete with code you are using around the problem area, any exceptions thrown etc. You will get a better response.
sandy6 30-Aug-11 7:57am    
Thanks!

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



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