timer.Stop(); camera.Stop(); this.Hide(); //this.Dispose(); } 位图bmp =新位图(this.Width,this.Height); this.DrawToBitmap(bmp,new Rectangle(0,0,this。宽度,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); 寻找代码的大胆部分,这是我输入ANDREW的代码。 i已经尝试过这段代码。但它可以在相机启动时保存2张图像。但我想仅在运动检测时保存图像与初始参考帧相比。而且只有相机窗口。此代码保存整个表单的图像。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 statisticprivate void timer_Elapsed( object sender, System.Timers.ElapsedEventArgs e ){try{Camera camera = cameraWindow.Camera;if (camera != null){// get number of frames for the last secondstatCount[statIndex] = camera.FramesReceived;// MessageBox.Show(statCount);// increment indexesif (++statIndex >= statLength)statIndex = 0;if (statReady < statLength)statReady++;float fps = 0;float b1 = 0;// calculate average valuefor (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.推荐答案在检查运动级别> 0的newframe事件上放置if语句然后保存img 我创建了一个名为SpyCam的类似项目,但它保存图像创建moview并仅为某个级别以上的运动帧写日志Put a if statment on the newframe event that check for motion level >0 then save imgI had made a similar project with same name "SpyCam" but it save image create moview and write log for only frame of motion above a certain level尝试此代码: if(detector.MotionLevel> 0.2) { 相机。 Lock(); Val ++; if(Val == 3 || Val> 3 ) { timer.Stop(); 相机。停止(); this.Hide(); } 位图bmp =新位图(this.Width,this.Height); this.DrawToBitmap(bmp,new Rectangle(0,0,this .Width,this.Height)); else { bmp.Save(C:\\SpyCam \\+ Val.ToString()+.jpg,System.Drawing。 Imaging.ImageFormat.Jpeg); camera.Unlock(); }try this code:if (detector.MotionLevel > 0.2) { camera.Lock(); Val++; if (Val == 3 || Val > 3) { timer.Stop(); camera.Stop(); this.Hide(); } Bitmap bmp = new Bitmap(this.Width, this.Height); this.DrawToBitmap(bmp, new Rectangle(0, 0, this.Width, this.Height)); else { bmp.Save("C:\\SpyCam\\" + Val.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); camera.Unlock(); } 这篇关于谁能为我提供一种在运动检测中保存图像的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 06:40