Exemple #1
0
        public void ProcessImage(object cancellationToken)
        {
            Unwrapping3       uwr   = null;
            CancellationToken token = (CancellationToken)cancellationToken;

            while (!token.IsCancellationRequested)
            {
                while (MainProcessingQuenue.TryDequeue(out PhaseImage result))
                {
                    if (uwr == null)
                    {
                        uwr = new Unwrapping3(result.Image);
                    }
                    else
                    {
                        uwr.UpdateParamsIfNeed(result.Image);
                    }
                    result.unwrapper = uwr;
                    result.CalculatePhaseImage();
                    result.Unwrap();
                    result.Process();
                    imagePool.AddImage(result);
                }
                Thread.Sleep(50);
            }
        }
        public virtual void Unwrap()
        {
            DateTime dt1 = DateTime.UtcNow;

            try
            {
                if (MaxProcessingStep < SettingsContainer.ProcessingStep.UnwrappedPhaseImage)
                {
                    return;
                }

                if (unwrapping == null)
                {
                    unwrapping = new Unwrapping3(Image);
                }
                else
                {
                    unwrapping.UpdateParamsIfNeed(Image);
                }

                //unwrapping.Unwrap(Image, out UwrReport rep);
                //unwrapper.Unwrap(Image, out UwrReport rep);
                unwrapping.UnwrapParallel(Image, out UwrReport rep);
                report = rep;

                /*
                 * double[,] matrix = new double[Image.GetUpperBound(0) + 1, Image.GetUpperBound(1) + 1];
                 * byte[,] mask = new byte[Image.GetUpperBound(0) + 1, Image.GetUpperBound(1) + 1];
                 * NativeMethods.unwrap(Marshal.UnsafeAddrOfPinnedArrayElement(Image, 0),
                 *  Marshal.UnsafeAddrOfPinnedArrayElement(matrix, 0),
                 *  Marshal.UnsafeAddrOfPinnedArrayElement(mask, 0), Image.GetUpperBound(1) + 1, Image.GetUpperBound(0) + 1, 0, 0, (char)0, (uint)1);
                 *
                 * Image = matrix;
                 */
                if (status <= SettingsContainer.ProcessingStep.WrappedPhaseImage)
                {
                    status = SettingsContainer.ProcessingStep.UnwrappedPhaseImage;
                }
            }
            catch (Exception ex)
            {
            }
            Unwrapping = DateTime.UtcNow.Subtract(dt1).TotalSeconds;
        }