static void xfer_XferNotify(object sender, SapXferNotifyEventArgs args) { // refresh view SapView View = args.Context as SapView; View.Show(); // refresh frame rate SapTransfer transfer = sender as SapTransfer; if (transfer.UpdateFrameRateStatistics()) { SapXferFrameRateInfo stats = transfer.FrameRateStatistics; float framerate = 0.0f; if (stats.IsLiveFrameRateAvailable) { framerate = stats.LiveFrameRate; } // check if frame rate is stalled if (stats.IsLiveFrameRateStalled) { Console.WriteLine("Live Frame rate is stalled."); } // update FPS only if the value changed by +/- 0.1 else if ((framerate > 0.0f) && (Math.Abs(lastFrameRate - framerate) > 0.1f)) { Console.WriteLine("Grabbing at {0} frames/sec", framerate); lastFrameRate = framerate; } } }
void xfer_XferNotify(object sender, SapXferNotifyEventArgs args) { // refresh view SapBuffer buffer = args.Context as SapBuffer; string filename = _save_dir + string.Format("Frame-{2}--Aux time-{0}--Host time-{1}.bmp", (args.AuxTimeStamp / 1e6).ToString(), (args.HostTimeStamp / 1e7).ToString(), (args.GenericParamValue0 - 1).ToString()); buffer.Save(filename, "-format bmp"); //buffer.Save("test.bmp", "-format bmp"); Console.WriteLine("Aux time: {0}, Host time: {1}, Frame: {2}", (args.AuxTimeStamp / 1e6).ToString(), (args.HostTimeStamp / 1e7).ToString(), args.GenericParamValue0.ToString()); SapTransfer transfer = sender as SapTransfer; if (transfer.UpdateFrameRateStatistics()) { SapXferFrameRateInfo stats = transfer.FrameRateStatistics; float framerate = 0.0f; if (stats.IsLiveFrameRateAvailable) { framerate = stats.LiveFrameRate; } // check if frame rate is stalled if (stats.IsLiveFrameRateStalled) { Console.WriteLine("Live Frame rate is stalled."); } } }