i'm using ANDREW KIRILLOV's algos and libraries. please help me out with a way to save images on motion detection else the camera keeps on running.
// On timer event - gather statistic
private void timer_Elapsed( object sender, System.Timers.ElapsedEventArgs e )
{
try
{
Camera camera = cameraWindow.Camera;
if (camera != null)
{
// get number of frames for the last second
statCount[statIndex] = camera.FramesReceived;
// MessageBox.Show(statCount);
// increment indexes
if (++statIndex >= statLength)
statIndex = 0;
if (statReady < statLength)
statReady++;
float fps = 0;
float b1 = 0;
// calculate average value
for (int i = 0; i < statReady; i++)
{
fps += statCount[i];
}
fps /= statReady;
statCount[statIndex] = 0;
b1 = fps;
if (b1 >= 2 && b1 <= 10)
{
Val++;
//SendSMS(Phone.ToString(), "Alert!Intruder Detected");
if (Val == 3 || Val > 3)
{
timer.Stop();
camera.Stop();
this.Hide();
//this.Dispose();
}
Bitmap bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(0, 0, this.Width, this.Height));
pictureBox1.Image = bmp;
///////
if (Val == 3 || Val > 3)
{
timer.Stop();
// camera.Stop();
this.Hide();
//this.Dispose();
}
else
{
bmp.Save("C:\\SpyCam\\" + Val.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
//bmp.Save("C:\\SpyCam\\" + System.DateTime.Now.Minute.ToString() + "" + System.DateTime.Now.Second.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
look for the bold part of the code that's what i entered into ANDREW's code.
i have tried this code. but it saves 2 images on camera startup. but i want to save images only on motion detection compared to an initial reference frame. and that too of the camera window only. this code saves image of the whole form.