Exemple #1
0
        public Bitmap GetNextFrame(out ImageStatus status)
        {
            status = null;

            if (latestBitmap == null)
            {
                return null;
            }

            try
            {
                Bitmap bmp = NativeHelpers.GetCurrentImage(out status);
                if (bmp != null)
                {
                    return (Bitmap)bmp.Clone();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }

            return (Bitmap)latestBitmap.Clone();
        }
Exemple #2
0
        public static Bitmap GetCurrentImage(out ImageStatus status)
        {
            Bitmap videoFrame = null;
            status = new ImageStatus();

            byte[] bitmapPixels = new byte[3 * imageWidth * imageHeight + 40 + 14 + 1];

            GetCurrentImage(bitmapPixels);
            GetCurrentImageStatus(status);

            using (MemoryStream memStr = new MemoryStream(bitmapPixels))
            {
                try
                {
                    videoFrame = (Bitmap)Bitmap.FromStream(memStr);
                }
                catch (Exception ex)
                {
                    try
                    {
                        videoFrame = new Bitmap(imageWidth, imageHeight);
                        using (Graphics g = Graphics.FromImage(videoFrame))
                        {
                            g.Clear(Color.White);
                            g.DrawString(ex.Message, s_ErrorFont, Brushes.Red, 10, 10);
                            g.Save();
                        }

                    }
                    catch(Exception ex2)
                    {
                        Trace.WriteLine(ex2.GetFullStackTrace());
                    }

                    Trace.WriteLine(ex.GetFullStackTrace());
                }
            }

            return videoFrame;
        }
Exemple #3
0
        public void UpdateFromFrameStatus(long frameNo, ImageStatus status)
        {
            bool updatedMade = false;

            if (TrackedObjectId != -1 && status.TrkdTargetIsTracked > 0)
            {
                TargetStar.X = status.TrkdTargetXPos;
                TargetStar.Y = status.TrkdTargetYPos;
                TargetStar.FWHM = status.TrkdTargetPsfInfo.FWHM;
                TargetStar.IsLocated = status.TrkdTargetIsLocated > 0;
                TargetStar.HasSaturatedPixels = status.TrkdTargetHasSaturatedPixels > 0;
                TargetStar.Measurement = status.TrkdTargetMeasurement;
                TargetStar.PsfFit.LoadFromNativePsfFitInfo(status.TrkdTargetPsfInfo, status.TrkdTargetResiduals);

                updatedMade = true;
            }

            if (GuidingObjectId != -1 && status.TrkdGuidingIsTracked > 0)
            {
                GuidingStar.X = status.TrkdGuidingXPos;
                GuidingStar.Y = status.TrkdGuidingYPos;
                GuidingStar.FWHM = status.TrkdGuidingPsfInfo.FWHM;
                GuidingStar.IsLocated = status.TrkdGuidingIsLocated > 0;
                GuidingStar.HasSaturatedPixels = status.TrkdGuidingHasSaturatedPixels > 0;
                GuidingStar.Measurement = status.TrkdGuidingMeasurement;
                GuidingStar.PsfFit.LoadFromNativePsfFitInfo(status.TrkdGuidingPsfInfo, status.TrkdGuidingResiduals);

                updatedMade = true;
            }

            if (updatedMade)
                LastTrackedFrameNo = frameNo;
        }
Exemple #4
0
 public FrameProcessingStatus(ImageStatus imgStatus)
 {
     FrameDiffSignature = 0;
     CameraFrameNo = imgStatus.UniqueFrameNo;
     CurrentSignatureRatio = imgStatus.CutOffRatio;
     IntegratedFrameNo = imgStatus.IntegratedFrameNo;
     CountedFrames = imgStatus.CountedFrames;
     DetectedIntegrationRate = imgStatus.DetectedIntegrationRate;
     DropedFramesSinceIntegrationLock = imgStatus.DropedFramesSinceIntegrationLock;
     PerformedAction = imgStatus.PerformedAction;
     PerformedActionProgress = imgStatus.PerformedActionProgress;
     StartExposureSystemTime = imgStatus.StartExposureSystemTime;
     EndExposureSystemTime = imgStatus.EndExposureSystemTime;
     StartExposureFrameNo = imgStatus.StartExposureFrameNo;
     EndExposureFrameNo = imgStatus.EndExposureFrameNo;
     OcrWorking = imgStatus.OcrWorking;
     OcrErrorsSinceLastReset = imgStatus.OcrErrorsSinceLastReset;
     UserIntegratonRateHint = imgStatus.UserIntegratonRateHint;
     TrkdGuidingXPos = imgStatus.TrkdGuidingXPos;
     TrkdGuidingYPos = imgStatus.TrkdGuidingYPos;
     TrkdGuidingIsTracked = imgStatus.TrkdGuidingIsTracked;
     TrkdGuidingMeasurement = imgStatus.TrkdGuidingMeasurement;
     TrkdTargetXPos = imgStatus.TrkdTargetXPos;
     TrkdTargetYPos = imgStatus.TrkdTargetYPos;
     TrkdTargetIsTracked = imgStatus.TrkdTargetIsTracked;
     TrkdTargetMeasurement = imgStatus.TrkdTargetMeasurement;
     TrkdTargetIsLocated = imgStatus.TrkdTargetIsLocated;
     TrkdGuidingIsLocated = imgStatus.TrkdGuidingIsLocated;
     TrkdTargetHasSaturatedPixels = imgStatus.TrkdTargetHasSaturatedPixels;
     TrkdGuidingHasSaturatedPixels = imgStatus.TrkdGuidingHasSaturatedPixels;
     TrkdTargetResiduals = imgStatus.TrkdTargetResiduals;
     TrkdGuidingResiduals = imgStatus.TrkdGuidingResiduals;
     TrkdTargetPsfInfo = imgStatus.TrkdTargetPsfInfo;
     TrkdGuidingPsfInfo = imgStatus.TrkdGuidingPsfInfo;
 }