public void Initialize(string folderPath, BackgroundStrippingParams backgroundStrippingParams, Color backgroundColor)
        {
            _folderPath = folderPath;
            _backgroundStrippingParams = backgroundStrippingParams;
            _backgroundColor           = backgroundColor;
            var firstImgPath = GetImageFilesHelper.GetImageFilesFromLocation(folderPath)[0];

            ImageCanvas.SetImage(firstImgPath);
            ClickHelpImage.Source = new BitmapImage(new Uri("ClickInputs/7.png", UriKind.Relative));
        }
Example #2
0
        public List <ImageClickInputDetails> GetClickPositionsForImgFolder(string imageDirPath, AutoConfigureImgPointsParams inputParams)
        {
            var filePaths = GetImageFilesHelper.GetImageFilesFromLocation(imageDirPath);

            var list = new List <ImageClickInputDetails>();

            for (var ctr = 0; ctr < filePaths.Count(); ctr++)
            {
                var details = GetImgClickInputDetails(filePaths[ctr], inputParams, ctr == 0);
                list.Add(details);
            }
            return(list);
        }
        public void GetUserInputForImages(string imageDirPath, ClickInputs existingInput)
        {
            ImageClickInputDetails = new List <ImageClickInputDetails>();

            if (existingInput != null && existingInput.ImageClickInputDetailsList != null)
            {
                ImageClickInputDetails = DeepClone(existingInput.ImageClickInputDetailsList) as List <ImageClickInputDetails>;
            }
            else
            {
                ImageClickInputDetails = new List <ImageClickInputDetails>();
            }

            FilePaths = GetImageFilesHelper.GetImageFilesFromLocation(imageDirPath);
            ProcessImage(0);
        }
Example #4
0
        private void SelectFolderHandler(object sender, SelectFolderEventArgs args)
        {
            var folderPath = args.FolderPath;

            if (!Directory.Exists(folderPath))
            {
                MessageBox.Show("Folder does not exist. It might have been moved or deleted.");
                return;
            }

            var imageFiles = GetImageFilesHelper.GetImageFilesFromLocation(folderPath);

            if (imageFiles == null || imageFiles.Length <= 0)
            {
                MessageBox.Show("Folder does not contain any images with jpg or jpeg format.");
                return;
            }

            SetFolderPath(folderPath, imageFiles);
        }
        private void Return(object sender, RoutedEventArgs routedEventArgs)
        {
            if (_minPixelsForBaseDisc == null)
            {
                MessageBox.Show("Please mark the area in the image that contains just the base disc.");
                return;
            }
            else if (_minPixelsForBaseDisc < 10)
            {
                MessageBox.Show("The height of the base disc should at least be 10 pixels.");
                return;
            }

            var quickProcessingWindow  = new QuickProcessingWindowHelper(ParentCanvas);
            var processor              = new AutoConfigureImgPoints.Processor();
            var markerPrcoessingParams = new MarkerProcessingParams
            {
                MarkerColorVariationPercent = 10,
                MarkerWidthPercent          = 5,
                MaximumMarkerCount          = 10
            };
            var @params = new AutoConfigureImgPointsParams
            {
                MarkerProcessingParams        = markerPrcoessingParams,
                BackgroundColor               = _backgroundColor,
                BackgroundStrippingParams     = _backgroundStrippingParams,
                MinPixelsForBaseDisc          = _minPixelsForBaseDisc.Value,
                MinPixelsForBaseDiscEndOfEdge = 10,
                ResizeHeight = 500,
                ResizeWidth  = 500
            };
            var clickPositions = processor.GetClickPositionsForImgFolder(_folderPath, @params);



            var gotResults = clickPositions != null && clickPositions.Count > 0 &&
                             clickPositions.Any(x => (x.ClickPositionListForImages != null && x.ClickPositionListForImages.Count > 0));

            if (!gotResults)
            {
                var statusMessages = new List <string>
                {
                    "Autoconfigure was unsuccessful. No image positions could be determined.",
                    "Please click on the 'Requirements' button to check how to take photos to support autoconfigure.",
                    "Press the cancel button to go back to entering the positions manually."
                };
                quickProcessingWindow.Close();
                var messageBox = new HelpMessageBox(statusMessages, null);
                messageBox.ShowDialog();
                return;
            }

            var fileCount           = GetImageFilesHelper.GetImageFilesFromLocation(_folderPath);
            var requiredCount       = GetRequiredClickInputsCount(fileCount);
            var identifiedCount     = 0;
            var innerStatusMessages = new List <string>();

            for (var ctr = 0; ctr < clickPositions.Count; ctr++)
            {
                var clickInput = clickPositions[ctr];
                var count      = clickInput != null && clickInput.ClickPositionListForImages != null? clickInput.ClickPositionListForImages.Count : 0;
                identifiedCount += count;

                if (ctr == 0)
                {
                    innerStatusMessages.Add(string.Format("{0}: {1} identified out of required 5.", clickInput == null? (ctr + 1).ToString() : clickInput.ImageName, count));
                }
                else
                {
                    innerStatusMessages.Add(string.Format("{0}: {1} identified out of required 4.", clickInput == null ? (ctr + 1).ToString() : clickInput.ImageName, count));
                }
            }

            quickProcessingWindow.Close();

            if (identifiedCount == requiredCount)
            {
                var statusMessages = new List <string>
                {
                    "AutoConfigure Successful!",
                    string.Format("All required {0} click positions were identified.", requiredCount),
                    "We will now display all the click positions for your review.."
                };

                var messageBox = new HelpMessageBox(statusMessages, null);
                messageBox.ShowDialog();
            }
            else
            {
                var statusMessages = new List <string>
                {
                    "AutoConfigure was partially successful in identifying the click positions.",
                    string.Format("{0} out of total of {1} positions could be identified.", identifiedCount, requiredCount),
                    "Below is a break down of the identified positions.",
                    "Click close to to review the identified positions and fill in the missed ones..."
                };

                var messageBox = new HelpMessageBox(statusMessages, innerStatusMessages);
                messageBox.ShowDialog();
            }

            if (AutoConfigured != null)
            {
                AutoConfigured(this,
                               new AutoConfigureSettingsEventArgs
                {
                    ClickInputs = new ClickInputs
                    {
                        ImageClickInputDetailsList = clickPositions,
                        Angles = null
                    }
                });
            }
        }