private void processFrame(Bgr <byte>[,] img, out long matchTimeMs) { var grayIm = img.ToGray(); linPyr = LinearizedMapPyramid.CreatePyramid(grayIm); //prepare linear-pyramid maps /******************************* match templates + particle filter stuff ******************************/ matchTimeMs = Diagnostics.MeasureTime(() => { predict(); update(); }); /******************************* match templates + particle filter stuff ******************************/ /******************************* reset tracking (if necessary) ******************************/ var p = particleFilter.MaxBy(x => x.Weight); if (p.Weight == 0) { if (resetClock.ElapsedMilliseconds > MAX_NONOBJ_TIME) { particleFilter = initialParticles; } return; } resetClock.Restart(); /******************************* reset tracking (if necessary) ******************************/ /********************************* output **************************************/ var metaData = getData(p.MetaDataRef); var text = String.Format("S:{0:00}, A:{1:00}", p.ModelParameters.Scale, p.ModelParameters.Angle); if (metaData != null) { //img.Draw(p.MetaData, new Bgr(Color.Blue), 1); img.Draw(metaData.Points.ToArray(), Bgr <byte> .Blue, 3); img.DrawAnnotation(metaData.BoundingRect, text, DotImaging.Font.Small); } Console.WriteLine(text); /********************************* output **************************************/ }