Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Application
Dear friends,
 
I am sitting here with the c# windows application.
 
I have set a picture box to capture image.
 
I want to detect motion from web camera.
 
I don't know how to set a path for capturing images continuously in to a folder.
 
Please explain me in codes.
 
In code project there are some project's motion_src.
 
I can't catch where they will call and close the program.
 
I am waiting for your valuable answers.
 
I've tried this till now:
 
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
 

 
namespace WinFormCharpWebCam
{
    //Design by Pongsakorn Poosankam
    public partial class mainWinForm : Form
    {
        public mainWinForm()
        {
            InitializeComponent();
        }
        WebCam webcam;
        private void mainWinForm_Load(object sender, EventArgs e)
        {
            webcam = new WebCam();
            webcam.InitializeWebCam(ref imgVideo);
        }
 
        private void bntStart_Click(object sender, EventArgs e)
        {
            webcam.Start();
            detector = new MotionDetector3();
            detectorType = 3;
            SetMotionDetector();
        }
        private void SetMotionDetector()
        {
            Camera camera = cameraWindow.Camera;
 
            // enable/disable motion alarm
            if (detector != null)
            {
                detector.MotionLevelCalculation = motionAlarmItem.Checked;
            }
 
            // set motion detector to camera
            if (camera != null)
            {
                camera.Lock();
                camera.MotionDetector = detector;
 
                // reset statistics
                statIndex = statReady = 0;
                camera.Unlock();
            }
        }
 
        private void bntStop_Click(object sender, EventArgs e)
        {
            webcam.Stop();
        }
 
        private void bntContinue_Click(object sender, EventArgs e)
        {
            webcam.Continue();
        }
 
        private void bntCapture_Click(object sender, EventArgs e)
        {
            imgCapture.Image = imgVideo.Image;
        }
 
        private void bntSave_Click(object sender, EventArgs e)
        {
            Helper.SaveImageCapture(imgCapture.Image);
         
        }
 
        private void bntVideoFormat_Click(object sender, EventArgs e)
        {
            webcam.ResolutionSetting();
        }
 
        private void bntVideoSource_Click(object sender, EventArgs e)
        {
            webcam.AdvanceSetting();
        }
 
        
    }
}
 
Till now I've been able to capture the image when I press a button but I would like to be able to capture the images automatically.
 
I don't know how to proceed, could you help?
 
Thank you in advance.
Posted 25-Jul-12 4:01am
Edited 25-Jul-12 6:41am
Joan Murt82.7K
v2
Comments
Wes Aday at 25-Jul-12 9:05am
   
It is highly unlikely that you will get an answer to this unless you go through this a clearly state what it is that you are doing. Looks like you are talking about 5 different things without a clear idea of what it is that you are doing.
Dhinesh kumar.V at 25-Jul-12 9:18am
   
actually i want to capture image continuosly from a webcam. and it will stored automatically in to a folder.
Wes Aday at 25-Jul-12 9:22am
   
So what exactly is it that you are doing? Where is the code the demonstrates your problem? We are not mind readers.
Dhinesh kumar.V at 25-Jul-12 9:39am
   
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
 

 
namespace WinFormCharpWebCam
{
//Design by Pongsakorn Poosankam
public partial class mainWinForm : Form
{
public mainWinForm()
{
InitializeComponent();
}
WebCam webcam;
private void mainWinForm_Load(object sender, EventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref imgVideo);
}
 
private void bntStart_Click(object sender, EventArgs e)
{
webcam.Start();
detector = new MotionDetector3();
detectorType = 3;
SetMotionDetector();
}
private void SetMotionDetector()
{
Camera camera = cameraWindow.Camera;
 
// enable/disable motion alarm
if (detector != null)
{
detector.MotionLevelCalculation = motionAlarmItem.Checked;
}
 
// set motion detector to camera
if (camera != null)
{
camera.Lock();
camera.MotionDetector = detector;
 
// reset statistics
statIndex = statReady = 0;
camera.Unlock();
}
}
 
private void bntStop_Click(object sender, EventArgs e)
{
webcam.Stop();
}
 
private void bntContinue_Click(object sender, EventArgs e)
{
webcam.Continue();
}
 
private void bntCapture_Click(object sender, EventArgs e)
{
imgCapture.Image = imgVideo.Image;
}
 
private void bntSave_Click(object sender, EventArgs e)
{
Helper.SaveImageCapture(imgCapture.Image);

}
 
private void bntVideoFormat_Click(object sender, EventArgs e)
{
webcam.ResolutionSetting();
}
 
private void bntVideoSource_Click(object sender, EventArgs e)
{
webcam.AdvanceSetting();
}
 

}
}
this is my code please help me.if i wanna click a button automatic capture the images in to a folder continuously.
Wes Aday at 25-Jul-12 9:49am
   
And so? This code won't even compile. Did you get all of the code from Pongsakorn Poosankam or did you just take bits and pieces?
Wes Aday at 25-Jul-12 9:53am
   
And your answer is right here in this Helper.SaveImageCapture. Just call that method when you want to save an image. I do not understand what your problem is.
Dhinesh kumar.V at 25-Jul-12 9:59am
   
i don't know sir.please tell me how to call..
Wes Aday at 25-Jul-12 10:03am
   
You are kidding me right? It's right there in the code and you cannot figure out how to call that method? Helper.SaveImageCapture(imgCapture.Image);
Dhinesh kumar.V at 25-Jul-12 10:09am
   
not like that sir.
helper.saveimagecapture(imgcapture.image); i have used in this program.it will capture the image only when i am pressed a button.
 
i want continuosly capture Motion images and it will saved into a folder.when i am click a button.
Wes Aday at 25-Jul-12 10:17am
   
Then call that function in a timer
Dhinesh kumar.V at 25-Jul-12 10:20am
   
k sir please don't close this question i will try and catch you.
Dhinesh kumar.V at 26-Jul-12 6:50am
   
dear sir,
first i want motion detect to capture images.after i will call the timer.please tell me in code to motion detect by webcamera and i will use the timer.
 
i really don't know the code for motion detection.please help me..
Dhinesh kumar.V at 25-Jul-12 10:02am
   
i want to capture motion.
Dhinesh kumar.V at 25-Jul-12 10:03am
   
i want to detect motion and it will be saved in a specified folder.
Dhinesh kumar.V at 25-Jul-12 9:41am
   
actually i want to capture images continuously.it will saved in to the folder.when i am press the button
Joan Murt at 25-Jul-12 11:43am
   
Dhinesh I've updated your question, check that it is still asking what you need/want and if you have to post more code samples, don't use the comments for that please, use the green "improve question" link that will allow you to update your question.
Good luck.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Dhinesh,
 
Your code is ok.
 
All you need is component Timer. You need to go in menu View -> Toolbox and add the component in your application. Then you click twice in the Timer to see the code for your project and call your function again.
 
The timer execute in miliseconds. If you wish a image at 1 minute, set the Timer Interval in 60000 (equal a 1 minute).
 
Do you understand?
  Permalink  
Comments
Dhinesh kumar.V at 26-Jul-12 7:04am
   
dear sir, first i want motion detect to capture images.after i will call the timer.please tell me in code to motion detect by webcamera and i will use the timer. i really don't know the code for motion detection.please help me..

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

  Print Answers RSS
0 Maciej Los 230
1 OriginalGriff 202
2 Richard MacCutchan 185
3 Tomas Takac 146
4 CPallini 125
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100