示例#1
0
        protected virtual bool CheckInputData(Image <Gray, ushort> inputImage, Image <Gray, byte> maskImage, int[,] pointArray, Image <Gray, double> meanVector, Image <Gray, double> stdVector)
        {
            try
            {
                if (!GeneralImageHandling.CheckImages(inputImage, maskImage, _width, _height, _logger))
                {
                    return(false);
                }

                if (meanVector == null || stdVector == null || meanVector.Width != inputImage.Height || stdVector.Width != inputImage.Height)
                {
                    _logger?.ErrorLog($"Error in the meanVector and stdVector length. meanVector height:{meanVector?.Height} stdVector height:{stdVector?.Height} meanVector height:{inputImage.Height}.", ClassName);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _logger?.ErrorLog($"Exception occured: {ex}", ClassName);
            }

            return(true);
        }
示例#2
0
        public bool Execute(List <NamedData> data, string name)
        {
            if (!IsInitialized)
            {
                _logger?.ErrorLog("Not initialized yet.", ClassName);
                return(false);
            }

            try
            {
                string[] enumNames = Enum.GetNames(typeof(DoubleNamingConvention));
                string   additionalExtensionName = string.Empty;

                Image <Gray, ushort>[] rawImages = GetEmguUShortImages("RawImages", data);
                int imageCounterRaw = rawImages?.Length ?? 0;

                Image <Gray, byte>[] maskImages = GetEmguByteImages("MaskImages", data);
                int imageCounterMask            = maskImages?.Length ?? 0;

                if (imageCounterMask != imageCounterRaw || imageCounterRaw > (enumNames?.Length ?? 0))
                {
                    _logger?.InfoLog("Input and mask image number OR enumNames number is not the same!", ClassName);
                    return(false);
                }

                int[][,] borderPointArrayLists = new int[imageCounterRaw][, ];

                for (int m = 0; m < imageCounterRaw; m++)
                {
                    if (!(GeneralImageHandling.CheckImages(rawImages[m], maskImages[m], _imageWidth, _imageHeight, _logger)))
                    {
                        continue;
                    }

                    if (!(AllocArrays() && ResetPointList()))
                    {
                        _logger?.InfoLog("Borderpoints array re-allocation failed.", ClassName);
                        continue;
                    }

                    if (enumNames.Length == imageCounterRaw)
                    {
                        additionalExtensionName = "_" + enumNames[m];
                    }

                    CalculatePoints(rawImages[m], maskImages[m], name, additionalExtensionName);

                    borderPointArrayLists[m] = _borderPoints;
                }

                data.Add(new BorderPointArraysNamedData(new BorderPointArrays(borderPointArrayLists), "contains the found border points", "BorderPointArrayList"));

                if (_showImages)
                {
                    SavePointLists(borderPointArrayLists, name, "PointList");
                }
            }
            catch (Exception ex)
            {
                _logger?.ErrorLog($"Exception during border points calculation: {ex}", ClassName);
                return(false);
            }

            return(true);
        }