public MootionDetect(string path) { //try to create the capture if (_capture == null) { try { _capture = new VideoCapture(path); _capture.SetCaptureProperty(CapProp.FrameWidth, 640); _capture.SetCaptureProperty(CapProp.FrameHeight, 360); _capture.SetCaptureProperty(CapProp.Fps, 30); _capture.SetCaptureProperty(CapProp.ConvertRgb, 0); CvInvoke.UseOptimized = true; CvInvoke.NumThreads = 4; } catch (NullReferenceException excpt) { //show errors if there is any MessageBox.Show(excpt.Message); } } if (_capture != null) //if camera capture has been successfully created { _motionHistory = new MotionHistory( 1.0, //in second, the duration of motion history you wants to keep 0.15, //in second, maxDelta for cvCalcMotionGradient 0.9); //in second, minDelta for cvCalcMotionGradient _capture.ImageGrabbed += ProcessFrame; _capture.Start(); } }
public JavsMotion() { AdjustableParameters = new Dictionary <string, ParameterProfile>(); AdjustableParameters["MinMotionArea"] = new ParameterProfile { Description = "Minimum Motion Size Threshold", MaxValue = 1000, MinValue = 5, CurrentValue = 100, Interval = 1 }; AdjustableParameters["MinMotionDistance"] = new ParameterProfile { Description = "Minimum Motion Distance Threshold", MaxValue = 1, MinValue = 0.005, CurrentValue = 0.05, Interval = 0.005 }; //Try out various background subtractors _backgroundSubtractor = new BackgroundSubtractorMOG2(); //Can the parameters taken by this constructor be adjusted during capture? _motionHistory = new MotionHistory( 1.0, //in second, the duration of motion history you wants to keep 0.05, //in second, maxDelta for cvCalcMotionGradient 0.5); //in second, minDelta for cvCalcMotionGradient }
public MainWindow() { InitializeComponent(); this.Unloaded += delegate { _kinectSensor.ColorStream.Disable(); }; this.Loaded += delegate { _motionHistory = new MotionHistory( 1.0, //in seconds, the duration of motion history you wants to keep 0.05, //in seconds, parameter for cvCalcMotionGradient 0.5); //in seconds, parameter for cvCalcMotionGradient _kinectSensor = KinectSensor.KinectSensors[0]; _kinectSensor.ColorStream.Enable(); _kinectSensor.Start(); BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (a, b) => Pulse(); bw.RunWorkerCompleted += (c, d) => bw.RunWorkerAsync(); bw.RunWorkerAsync(); }; }
public Form1(ImageBox image) { InitializeComponent(); foreground = image; time = new Stopwatch(); //try to create the capture if (_capture == null) { try { _capture = new Capture(0); time.Start(); } catch (NullReferenceException excpt) { //show errors if there is any MessageBox.Show(excpt.Message); } } if (_capture != null) //if camera capture has been successfully created { _motionHistory = new MotionHistory( 0.01, //in second, the duration of motion history you wants to keep 0.05, //in second, any motion in interval more than this will not be considered 0.05); //in second, any motion in interval less than this will not be considered _capture.ImageGrabbed += ProcessFrame; _capture.Start(); } }
public MotionDetection() { if (_capture == null) { try { _capture = new VideoCapture(); } catch (NullReferenceException excpt) { //show errors if there is any //MessageBox.Show(excpt.Message); throw excpt; } } if (_capture != null) //if camera capture has been successfully created { _motionHistory = new MotionHistory( 1.0, //in second, the duration of motion history you wants to keep 0.05, //in second, maxDelta for cvCalcMotionGradient 0.5); //in second, minDelta for cvCalcMotionGradient _capture.ImageGrabbed += ProcessFrame; //_capture.Start(); } }
public Form1() { InitializeComponent(); //try to create the capture if (_capture == null) { try { _capture = new Capture(); } catch (NullReferenceException excpt) { //show errors if there is any MessageBox.Show(excpt.Message); } } if (_capture != null) //if camera capture has been successfully created { _motionHistory = new MotionHistory( 1.0, //in second, the duration of motion history you wants to keep 0.05, //in second, maxDelta for cvCalcMotionGradient 0.5); //in second, minDelta for cvCalcMotionGradient _capture.ImageGrabbed += ProcessFrame; _capture.Start(); } }
private void captureTwoComboBox_SelectedIndexChanged(object sender, EventArgs e) { camIndexTwo = captureTwoComboBox.SelectedIndex; //try to create the capture if (_captureTwo == null) { try { _captureTwo = new VideoCapture(camIndexTwo); //Create Instance of First Camera } catch (NullReferenceException excpt) { //show errors if there is any MessageBox.Show(excpt.Message); } } if (_captureTwo != null) //if camera capture has been successfully created { _motionHistoryTwo = new MotionHistory( 1.0, //in second, the duration of motion history you wants to keep 0.05, //in second, maxDelta for cvCalcMotionGradient 0.5); //in second, minDelta for cvCalcMotionGradient captureTwoStartButton.Enabled = true; } captureTwoComboBox.Enabled = false; }
public BlobDetection() { InitializeComponent(); _motionHistory = new MotionHistory( 1.0, //in second, the duration of motion history you wants to keep 0.05, //in second, maxDelta for cvCalcMotionGradient 0.5); //in second, minDelta for cvCalcMotionGradient }
public void Reset() { MotionHistory oldMotionHistory = _motionHistory; _motionHistory = new MotionHistory( 1, //in second, the duration of motion history you wants to keep 0.05, //in second, maxDelta for cvCalcMotionGradient 0.5); //in second, minDelta for cvCalcMotionGradient if (oldMotionHistory != null) { oldMotionHistory.Dispose(); } }
public void InitalizeMotion() { //_motionHistory = new MotionHistory( // 1.0, //mhiDuration In second, the duration of motion history you wants to keep // 0.05, //maxTimeDelta In second. Any change happens between a time interval greater than this will not be considerred // 0.5); //minTimeDelta In second. Any change happens between a time interval smaller than this will not be considerred. _motionHistory = new MotionHistory( 2.0, //mhiDuration In second, the duration of motion history you wants to keep 0.08, //maxTimeDelta In second. Any change happens between a time interval greater than this will not be considerred 0.5); //minTimeDelta In second. Any change happens between a time interval smaller than this will not be considerred. MotionSum = Vector2.One; }
/// <summary> /// Motion Detector Constructor /// </summary> /// <param name="imagingData">Common Image Processing Imaging Data</param> public MotionDetector(IImageData imagingData) { ImagingData = imagingData; //Set values for properties MinMotionAreaThreshold = DEFAULT_MIN_MOTION_AREA_THRESHOLD; MinMotionPixelFactor = DEFAULT_MIN_MOTION_PIXEL_FACTOR; GrayThreshold = DEFAULT_GRAY_THRESHOLD; //Instantiate private members _motionHistory = new MotionHistory(MOTION_HISTORY_DURATION, MOTION_HISTORY_MAX_DELTA, MOTION_HISTORY_MIN_DELTA); _forgroundDetector = new BackgroundSubtractorMOG2(); _segMask = new Mat(); _foreground = new Mat(); ComputerVisionMonitors = new Dictionary <eComputerVisionMonitor, IComputerVisionMonitor>(); }
public PBDPanel() { InitializeComponent(); StateManager.Instance.StateChange += StateChange; this.DataContext = EditWorkflowManager.Instance.CurrentWorkflow; m_MotionHistory = new MotionHistory( 0.1, //in second, the duration of motion history you wants to keep 0.05, //in second, parameter for cvCalcMotionGradient 0.5); //in second, parameter for cvCalcMotionGradient m_PreviousMoves = new int[m_ARRAYSIZE]; for (int i = 0; i < m_ARRAYSIZE; i++) { m_PreviousMoves[i] = 0; } }
LineSegment2DF Line2 = new LineSegment2DF(); //十字光标 public Form1() { InitializeComponent(); _motionDetect = new BackgroundSubtractorMOG2();//默认参数实例化类。 //_motionhistory = new MotionHistory(0.01, 0.05, 0.5); OpenFileDialog op = new OpenFileDialog(); string path = ""; _capture = new Capture("1.avi"); //打开运行目录下的1.avi视频。 if (_capture != null) //if camera capture has been successfully created { _motionhistory = new MotionHistory( 0.1, //运动持续时间。 0.5, //运动最长时间。 0.05); //运动最短时间。 _capture.ImageGrabbed += frame; //捕捉帧触发事件 _capture.Start(); //开启捕捉真事件。 } }
public void Start() { Console.WriteLine("Try start " + _connectionString); try { _motionHistory = new MotionHistory( Duration, //in second, the duration of motion history you wants to keep MaxDelta, //in second, maxDelta for cvCalcMotionGradient MinDelta); //in second, minDelta for cvCalcMotionGradient _capture = new Capture(_connectionString); _capture.ImageGrabbed += ProcessFrame; _capture.Start(); //Console.WriteLine("Has started " + _connectionString); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { isStarted = true; lblRemianingTime.Visible = true; button2.Enabled = true; button1.Enabled = false; xdoc = XDocument.Load("AEISConfig.xml"); grabber = new Capture(path + "vids\\MVI_3649_1_1.avi"); // grabber.QueryFrame(); //Initialize the FrameGraber event Application.Idle += new EventHandler(FrameGrabber); button1.Enabled = false; button2.Enabled = true; ///motion detection start if (grabber == null) { try { grabber = new Capture(); } catch (NullReferenceException excpt) { //show errors if there is any MessageBox.Show(excpt.Message); } } if (grabber != null) //if camera capture has been successfully created { _motionHistory = new MotionHistory( 2.0, //in second, the duration of motion history you wants to keep 0.05, //in second, parameter for cvCalcMotionGradient 0.5); //in second, parameter for cvCalcMotionGradient //Application.Idle += ProcessFrame; } ///motion detection end }
void FrameGrabber(object sender, EventArgs e) { try { //Get the current frame form capture device currentFrame = grabber.QueryFrame().Resize(520, 340, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); } catch (NullReferenceException e1) { _motionHistory = new MotionHistory(2.0, 0.05, 0.5); _forgroundDetector = null; motionQueue.Clear(); helpQueue.Clear(); grabber = new Capture(vidlist[excnt]); excnt++; if (excnt == 5) { excnt = 0; } currentFrame = grabber.QueryFrame().Resize(520, 340, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); green1 = false; green2 = false; green3 = false; green4 = false; red1 = false; red2 = false; red3 = false; red4 = false; } //Convert it to Grayscale gray = currentFrame.Convert <Gray, Byte>(); //Face Detector MCvAvgComp[][] facesDetected = gray.DetectHaarCascade( face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); //Action for each element detected foreach (MCvAvgComp f in facesDetected[0]) { t = t + 1; result = currentFrame.Copy(f.rect).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //MessageBox.Show("wiidth " + f.rect.Width + " height " + f.rect.Height + " area " + f.rect.Width * f.rect.Height); if (f.rect.Width > 80) { continue; } //draw the face detected in the 0th (gray) channel with blue color if (showHand) { currentFrame.Draw(f.rect, new Bgr(Color.LightGreen), 2); } int nearespos = nearestPosition(f.rect.X, f.rect.Y); if (helpQueue.ToArray().ToList().IndexOf(nearespos) == -1) { //lbAlerts.Items.Add("Help request at #" + nearespos.ToString()); dgAlerts.Rows.Add("Help Request", nearespos.ToString()); DB_Connect.InsertQuery("INSERT INTO alert_tab(exam_id,position_id,alert_type,alert_time) VALUES(" + examid + "," + nearespos.ToString() + ",'H','" + DateTime.Now + "')"); dgAlerts.FirstDisplayedScrollingRowIndex = dgAlerts.RowCount - 1; //GCM - help //AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification(); //string strResponse = apnGCM.SendNotification(regID, nearespos.ToString() + " "+ DateTime.Now, "H"); if (nearespos == 1) { green1 = true; } else if (nearespos == 2) { green2 = true; } else if (nearespos == 3) { green3 = true; } else if (nearespos == 4) { green4 = true; } if (helpQueue.Count == 10) { helpQueue.Dequeue(); helpQueue.Enqueue(nearespos); } else { helpQueue.Enqueue(nearespos); } } } //Show the faces procesed and recognized imageBoxFrameGrabber.Image = ProcessFrame(currentFrame); if (captureOutput == null && xdoc.Descendants("RecordVideo").First().Value == "1") { MessageBox.Show("reording start"); captureOutput = new VideoWriter(@"video" + examid + ".avi", (int)grabber.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FOURCC), 15, 520, 340, true); } if (currentFrame != null && xdoc.Descendants("RecordVideo").First().Value == "1") { captureOutput.WriteFrame <Bgr, Byte>(currentFrame); } }
public MotionDetection() { _motionHistory = new MotionHistory(1.0, 0.05, 0.5); }