Exemple #1
0
 public void AddImage(PhaseImage phaseImage)
 {
     lock (locker)
     {
         images.Add(phaseImage);
     }
 }
Exemple #2
0
 public void PutImage(PhaseImage phaseImage)
 {
     //MainProcessingQuenue.TryDequeue(out var phaseImage1);
     if (MainProcessingQuenue.Count > 50)
     {
         MainProcessingQuenue.TryDequeue(out var phaseImage1);
     }
     MainProcessingQuenue.Enqueue(phaseImage);
 }
Exemple #3
0
        /// <summary>
        /// Работает только с самым последним изображением, если изображений становится больше, чем обработчиков, лишние отбрасываются.
        /// </summary>
        /// <param name="cancellationToken"></param>
        public void MainProcessImage(object cancellationToken)
        {
            CancellationToken token = (CancellationToken)cancellationToken;

            while (!token.IsCancellationRequested)
            {
                PhaseImage result = null;
                while (MainProcessingQuenue.TryDequeue(out result))
                {
                    if (result != null)
                    {
                        logger.Debug(string.Format("Processing image (recorded at {0})", result.RecordingTime));
                        result.CalculatePhaseImage();
                        result.Unwrap();
                        result.Process();
                        if (PhaseImageInterfaceSender != null)
                        {
                            PhaseImageInterfaceSender.Invoke(result);
                        }
                    }
                    while (MainProcessingQuenue.TryDequeue(out result) && !MainProcessingQuenue.IsEmpty)
                    {
                        ;
                    }

                    //logger.Debug(string.Format("Decuenue image (rec. time: {1}) from processing queue. Total {0} images in queue.", MainProcessingQuenue.Count, result.RecordingTime));
                    //if (!MainProcessingQuenue.IsEmpty)
                    //{
                    //    logger.Debug("Using additional threads");
                    //    if (SecondaryImageProcessors!=null)
                    //        SecondaryProcessingQuenue.Enqueue(result);
                    //}
                    //else
                    //{
                    //    logger.Debug("Processing image in main thread additional threads");
                    //    if (result != null)
                    //    {
                    //        logger.Debug(string.Format("Processing image (recorded at {0})", result.RecordingTime));
                    //        result.CalculatePhaseImage();
                    //        result.Unwrap();
                    //        result.Process();
                    //        if (PhaseImageInterfaceSender != null)
                    //            PhaseImageInterfaceSender.Invoke(result);
                    //        if (PhaseImageSender != null)
                    //            PhaseImageSender.Invoke(result);
                    //    }
                    //    else
                    //    {
                    //        logger.Debug("No images in queue");
                    //    }
                    //}
                }

                //Thread.Sleep(50);
            }
        }
Exemple #4
0
 public static void Calc()
 {
     while (phaseImages.Count != 0)
     {
         PhaseImage phaseIm = phaseImages.Dequeue();
         phaseIm.CalculatePhaseImage();
         phaseIm.Unwrap();
         //phaseIm.Process();
     }
 }
 public static void init()
 {
     capt = new ModelImageCapture(1000, 2000);
     capt.CreateImagesForStepMethod(1, 4);
     while (PhaseImageFactory.phaseImages.Count < 1)
     {
         PhaseImageFactory.AddImage(capt.GetImage());
     }
     BufferPhaseImage = PhaseImageFactory.phaseImages.Dequeue();
     reserve          = (double[, ])BufferPhaseImage.Image.Clone();
 }
        private void AddImage(Mat image)
        {
            lock (locker)
            {
                if (settings.recordingType == SettingsContainer.RecordingType.Camera)
                {
                    BufferPhaseImage = new CameraImage(image)
                    {
                        MaxProcessingStep = settings.maxProcessingStep
                    };
                    BufferPhaseImage.Wavelength = this.settings.wavelength;
                    imageProcessor.PutImage(BufferPhaseImage);
                }
                else if (settings.recordingType == SettingsContainer.RecordingType.Hilbert)
                {
                    BufferPhaseImage = new HilbertPhaseImage(image)
                    {
                        MaxProcessingStep = settings.maxProcessingStep
                    };
                    BufferPhaseImage.Wavelength = this.settings.wavelength;
                    imageProcessor.PutImage(BufferPhaseImage);
                }
                else if (settings.recordingType == SettingsContainer.RecordingType.Step)
                {
                    StepPhaseImage stepPhaseImage = BufferPhaseImage as StepPhaseImage;

                    if (stepPhaseImage != null)
                    {
                        if (stepPhaseImage.StepNumber < settings.MaximumSteps)
                        {
                            stepPhaseImage.AddStep(image);
                        }
                        else
                        {
                            imageProcessor.PutImage(BufferPhaseImage);
                            BufferPhaseImage = new StepPhaseImage(image)
                            {
                                MaxProcessingStep = settings.maxProcessingStep
                            };;
                            BufferPhaseImage.Wavelength = this.settings.wavelength;
                        }
                    }
                    else
                    {
                        BufferPhaseImage = new StepPhaseImage(image)
                        {
                            MaxProcessingStep = settings.maxProcessingStep
                        };;
                        BufferPhaseImage.Wavelength = this.settings.wavelength;
                    }
                }
            }
        }
Exemple #7
0
 public static void AddImage(double[,] image)
 {
     lock (locker)
     {
         if (settings.recordingType == SettingsContainer.RecordingType.Step)
         {
             StepPhaseImage stepPhaseImage = BufferPhaseImage as StepPhaseImage;
             if (stepPhaseImage != null)
             {
                 if (stepPhaseImage.StepNumber < settings.MaximumSteps)
                 {
                     stepPhaseImage.AddStep(image);
                 }
                 else
                 {
                     phaseImages.Enqueue(BufferPhaseImage);
                     BufferPhaseImage = new StepPhaseImage(image)
                     {
                         MaxProcessingStep = settings.maxProcessingStep
                     };;
                 }
             }
             else
             {
                 BufferPhaseImage = new StepPhaseImage(image)
                 {
                     MaxProcessingStep = settings.maxProcessingStep
                 };;
             }
         }
         else if (settings.recordingType == SettingsContainer.RecordingType.Camera)
         {
             BufferPhaseImage = new CameraImage(image);
             phaseImages.Enqueue(BufferPhaseImage);
         }
         else if (settings.recordingType == SettingsContainer.RecordingType.Hilbert)
         {
             BufferPhaseImage = new HilbertPhaseImage(image);
             phaseImages.Enqueue(BufferPhaseImage);
         }
     }
 }
 private void ApplySettings()
 {
     imageCapture.UpdateCamera(settings.Camera);
     imageCapture.UpdateFramePause(settings.FramePause);
     imageCapture.UpdateMaxFrameCounter(settings.MaximumSteps);
     if (settings.model)
     {
         imageCapture.Pause();
         lock (locker)
             BufferPhaseImage = null;
         imageCapture2.PauseRelease();
     }
     else
     {
         imageCapture2.Pause();
         lock (locker)
             BufferPhaseImage = null;
         imageCapture.PauseRelease();
     }
 }
Exemple #9
0
 public bool TryGetImage(out PhaseImage phaseImage)
 {
     lock (locker)
     {
         phaseImage = null;
         if (images.Count > 0)
         {
             images.RemoveAll(item => item.RecordingTime < LastImageRecordingTime);
             images.Sort((item1, item2) => item1.RecordingTime > item2.RecordingTime?1:(item1.RecordingTime < item2.RecordingTime?-1:0));
             while (images.Count > 30)
             {
                 images.RemoveAt(0);
             }
             phaseImage             = images[0];
             LastImageRecordingTime = phaseImage.RecordingTime;
             images.RemoveAt(0);
             return(true);
         }
         return(false);
     }
 }
        private void ApplySettings()
        {
            imageCapture.UpdateCamera(settings.Camera);
            imageCapture.UpdateFramePause(settings.FramePause);
            imageCapture.UpdateMaxFrameCounter(settings.MaximumSteps);
            if (settings.model)
            {
                imageCapture.Pause();
                lock (locker)
                    BufferPhaseImage = null;
                imageCapture2.PauseRelease();
            }
            else
            {
                imageCapture2.Pause();
                lock (locker)
                    BufferPhaseImage = null;
                imageCapture.PauseRelease();
            }

            if (settings.arduino)
            {
                if (ArduinoWorker == null)
                {
                    ArduinoWorker = new ArduinoWorker();
                    ArduinoWorker.init();
                    imageCapture.action += ArduinoWorker.Action;
                }
            }
            else
            {
                if (ArduinoWorker != null)
                {
                    ArduinoWorker.Stop();
                    imageCapture.action -= ArduinoWorker.Action;
                    ArduinoWorker        = null;
                }
            }
        }
Exemple #11
0
 public void PutImage(PhaseImage phaseImage)
 {
     MainProcessingQuenue.TryDequeue(out var phaseImage1);
     MainProcessingQuenue.Enqueue(phaseImage);
 }
Exemple #12
0
 public bool TryGetImage(out PhaseImage phaseImage)
 {
     return(imagePool.TryGetImage(out phaseImage));
 }
 public bool TryGetImage(out PhaseImage phaseImage)
 {
     return(imageProcessor.TryGetImage(out phaseImage));
 }