public HandDetector(BeGazeData beGazeData, Video video, BackgroundWorker backgroundWorker) { BeGazeData = beGazeData; Video = video; _backgroundWorker = backgroundWorker; HgdData = new HgdData(); StopBool = false; }
/// <summary> /// This will measure the distance between the gaze point and the closest hand for each frame in the video. /// For each time step the hands are detected and compared to the (x, y)-coordinates of the gaze. The /// distance between the two is recorded and stored in the HgdData. /// </summary> /// <returns></returns> public HgdData MeasureRawHgd() { StopBool = false; List <float> rawDistance = new List <float>(); GC.Collect(); GC.WaitForPendingFinalizers(); for (int index = 0; index < Video.FrameCount; index++) { if (StopBool) { break; } PointF coordinates = BeGazeData.GetCoordinatePoint(index); Image <Bgr, byte> frame = Video.GetBgrImageFrame(); float distance = float.NaN; if (frame != null) { distance = MeasureHgd(frame, coordinates); frame.Dispose(); } rawDistance.Add(distance); Progress = Convert.ToInt32(((double)index / Video.FrameCount) * 100); if (Progress % 2 == 0) { _backgroundWorker.ReportProgress(Progress); } } HgdData.RawDistance = rawDistance; return(HgdData); }