示例#1
0
        /// <summary>
        /// Converts the image.
        /// </summary>
        /// <param name="pathIn">The path in.</param>
        /// <param name="pathOut">The path out.</param>
        public void ConvertImages(string pathIn, string pathOut)
        {
            int counter    = 0;
            var fileList   = Directory.GetFiles(@pathIn);
            int count      = fileList.Length;
            var multiplier = 100d / count;

            Directory.CreateDirectory(Constants.PRE_FOLDER_BACKGROUND);
            Directory.CreateDirectory(Constants.PRE_FOLDER_HUMAN);

            foreach (string fileName in fileList)
            {
                BitmapSource image = new BitmapImage(new Uri(fileName, UriKind.RelativeOrAbsolute));

                var preprocessedArray = PreprocessImage(image, Filter.Sobel);
                var preprocessedImage = AuxiliaryMethods.BitmapSourceFromArray(preprocessedArray, false);
                var resizedImage      = ResizeImage(preprocessedImage);

                resizedImage.SaveImage($"{pathOut}\\{counter}.png");

                double percentage = counter * multiplier;

                counter++;

                ReportProgress?.Invoke(this, new ProgressArgs {
                    Percentage = percentage, Message = string.Empty
                });
            }
        }
示例#2
0
        /// <summary>
        /// Alls the passes of window.
        /// </summary>
        /// <param name="src">The source.</param>
        /// <param name="step">The step.</param>
        /// <returns></returns>
        public Task <List <RecognizedObject>[]> AllPassesOfWindow(BitmapSource src, int step)
        {
            var preprocessedArray = _imageProcessor.PreprocessImage(src, Filter.Sobel);
            var preprocessedImage = AuxiliaryMethods.BitmapSourceFromArray(preprocessedArray, false);

            int width  = Constants.WIDTH;
            int height = Constants.HEIGHT;

            var taskList = new List <Task <List <RecognizedObject> > >();

            while (width < preprocessedImage.Width && height < preprocessedImage.Height)
            {
                src.Freeze();
                taskList.Add(OnePassOfWindow(src, width, height, step));
                width  = (int)Math.Round(width * 1.5);
                height = (int)Math.Round(height * 1.5);
            }

            return(Task.WhenAll(taskList));
        }