/// <summary> /// Start receiving jpeg frames via the FrameAvailable event. /// </summary> /// <param name="dispatcher">The UI dispatcher</param> /// <param name="sizeHint">The size you plan to display, this is just a hint</param> /// <param name="fps">The fps setting, defaults to maximum FPS</param> public void StartJpegStream(CoreDispatcher dispatcher, int sizeHint = 640, CameraFps fps = CameraFps.Max) { int resolution = (sizeHint <= 320) ? 8 : 32; if (CameraUrl == null) { return; } try { mjpeg = new MjpegDecoder(dispatcher); mjpeg.FrameReady += OnFrameReady; mjpeg.Error += OnError; string requestStr = String.Format("{0}videostream.cgi?resolution={1}&rate={2}", CameraUrl, resolution, (byte)fps); int msPerFrames = GetMillisecondsPerFrame(fps); mjpeg.GetVideoStream(new Uri(requestStr), msPerFrames, GetCredentials()); } catch (Exception e) { OnError(this, new ErrorEventArgs() { Message = e.Message }); Log.WriteLine("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString()); throw; } }
private int GetMillisecondsPerFrame(CameraFps fps) { double milliseconds = 50; foreach (FpsInfo i in FpsItems) { if (i.Value >= fps) { milliseconds = i.MillisecondsPerFrame; break; } } return((int)milliseconds); }
internal static extern CameraError GetPreviewFps(IntPtr handle, out CameraFps fps);
public FpsInfo(string caption, CameraFps value, double msPerFrame) { Caption = caption; Value = value; MillisecondsPerFrame = msPerFrame; }