public KLDemo() { InitializeComponent(); lkStorage = new PyrLKStorage <FlowColor>(pyrLevels: 1); try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); prevIm = videoCapture.ReadAs <FlowColor, float>(); oldPositions = prevIm. Convert <Gray, float>(). GoodFeaturesToTrack(winSize, 0.05f) .Select(x => new PointF(x.X, x.Y)).Take(100).ToList(); #else videoCapture = new CameraCapture(0); oldPositions = new List <PointF>(); prevIm = new Image <FlowColor, float>(imgSize); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = imgSize; } this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }
public KLDemo() { InitializeComponent(); lkStorage = new PyrLKStorage<FlowColor>(pyrLevels: 1); try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); prevIm = videoCapture.ReadAs<FlowColor, float>(); oldPositions = prevIm. Convert<Gray, float>(). GoodFeaturesToTrack(winSize, 0.05f) .Select(x => new PointF(x.X, x.Y)).Take(100).ToList(); #else videoCapture = new CameraCapture(0); oldPositions = new List<PointF>(); prevIm = new Image<FlowColor, float>(imgSize); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if(videoCapture is CameraCapture) (videoCapture as CameraCapture).FrameSize = imgSize; this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }