public void ProcessFrameAsync(VideoFrameWrapper frame, Bitmap bmp) { lock (m_SyncLock) { if (m_WaitingForFrameToSolve && m_TelescopeIsConnected && m_TelescopePositionIsKnown) { var mvf = new MinimalVideoFrame(frame, bmp); m_CurrentFramePixels = mvf.ImageArray as int[,]; if (!m_FOVKnown) { // http://www.wilmslowastro.com/software/formulae.htm // arc sec per pixel = pixel size [um] * 206.3 / focal length [mm] int width = m_CurrentFramePixels.GetLength(0); int height = m_CurrentFramePixels.GetLength(1); m_FieldOfViewDegrees = (Math.Sqrt(width * width + height * height) * 206.3 * ASSUMED_MAX_PIXEL_SIZE_MICRONS / m_FocalLengthMillimeters) / 3600; } m_WaitingForFrameToSolve = false; } } }
private void PaintVideoFrameCallback(VideoFrameWrapper frame, Bitmap bmp) { if (m_VideoFrameCopyRequested) { try { m_LastRenderedFrame = new MinimalVideoFrame(frame, new Bitmap(bmp)); } catch (Exception ex) { Trace.WriteLine(ex.GetFullStackTrace()); } finally { m_VideoFrameCopyRequested = false; m_GetNextVideoFrameSignal.Set(); } } m_MainForm.PaintVideoFrame(frame, bmp); }
internal IVideoFrame GetCurrentFrame() { m_GetNextVideoFrameSignal.Reset(); m_LastRenderedFrame = null; m_VideoFrameCopyRequested = true; m_GetNextVideoFrameSignal.WaitOne(); return m_LastRenderedFrame; }