public ContainerOfControls()
        {
            InitializeComponent();
            compareImages = new CompareImages();

            var config     = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
            var startIndex = config.AppSettings.Settings["StartIndex"];

            if (!int.TryParse(startIndex?.ToString(), out start))
            {
                start = 0;
            }
        }
示例#2
0
        private void generateSnapshot()
        {
            Bitmap img;
            Bitmap scr = captureScreen();

            int screenWidth = scr.Width;
            int screenHeight = scr.Height;
            int index = 0;
            int currentPieceWidth = sliceWidth, currentPieceHeight = sliceHeight;

            for (int currentRow = 0; currentRow < screenHeight; currentRow += sliceHeight)            // loop through Y
            {
                for (int currentColumn = 0; currentColumn < screenWidth; currentColumn += sliceWidth) // loop through X
                {
                    if ((currentColumn + currentPieceWidth) > screenWidth)                            // tiles smaller than slice width
                    {
                        currentPieceWidth = screenWidth - currentColumn;
                    }

                    if ((currentRow + currentPieceHeight) > screenHeight) // tiles smaller than slice height
                    {
                        currentPieceHeight = screenHeight - currentRow;
                    }

                    //number the current image
                    index++;
                    //copy the current slice to the image array
                    img = scr.Clone(new Rectangle(currentColumn, currentRow, currentPieceWidth, currentPieceHeight), scr.PixelFormat);

                    if ((pieces.Count - 1 >= index) && (pieces[index] != null))                                                      // If the number of pieces is greater than the current piece, and the current piece is there...
                    {
                        if (CompareImages.Compare(img, ((Piece)pieces[index]).getImg(0)) != CompareImages.CompareResult.ciCompareOk) // compare them. If not matching... continue...
                        {
                            imagesToSend = imagesToSend + String.Format("\nimage{0:000}", index);                                    // add this image to the list of updated images

                            Piece newPiece = new Piece(index, img);                                                                  // create a new 'piece' object
                            pieces[index] = newPiece;                                                                                // replace the current piece in the array.
                            imagesToSend  = imagesToSend + "/" + newPiece.getCheckSum();
                        }
                    }
                    else
                    {
                        Piece newPiece = new Piece(index, img); // it doesnt exist
                        pieces.Add(newPiece);                   // so add it.
                    }
                } // end X loop
                currentPieceWidth = sliceWidth; // reset the piece width back to slice width...
            } // end Y loop
        } // end function
示例#3
0
        // public static bool Wait = false;
        // static WaveOutCapabilities Cap;
        static void Main(string[] args)
        {
            var PathFirstImage  = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\Screenshot1.png";
            var PathSecondImage = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\Screenshot2.png";
            var firstImage      = new Bitmap(PathFirstImage, true);
            var secondImage     = new Bitmap(PathSecondImage, true);

            Console.WriteLine(firstImage.PixelFormat);
            Console.WriteLine(secondImage.PixelFormat);

            CompareImages compareImages  = new CompareImages();
            var           coordinateList = compareImages.ImageCompareArray(firstImage, secondImage);

            new MouseMove(coordinateList);

            //  var enumerator = new MMDeviceEnumerator();
            //var device =   enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
            //  for (int i = 0; i < WaveOut.DeviceCount; i++)
            //  {
            //      //var cap = WaveOut.GetCapabilities(1);

            //      //Console.WriteLine("{0}: {1}", i, cap.ProductName);
            //     var cap =  enumerator.GetDevice(device.ID);

            //      Console.WriteLine(cap);
            //  }


            // var SndDevice = enumerator.GetDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console).ID);

            //var Wait = true;
            //var c = new Ears();
            //int i = 0;
            //while (true)
            //{
            //  Wait  = c.Listen(30000).Result;


            //    Console.WriteLine();
            Console.WriteLine();
            Console.ReadLine();
        }
        /// <summary>
        ///     Main function.
        /// </summary>
        /// <param name="args"><c>--clientSecret</c> and <c>--clientId</c> are required arguments, <c>--baseUrl</c> is optional.</param>
        private static void Main(string[] args)
        {
            string clientSecret, clientId, baseUrl;

            ProcessArguments(args, out clientSecret, out clientId, out baseUrl);

            try
            {
                var api = new ImagingApi(clientSecret, clientId, baseUrl);

                PrepareOutput();

                Console.WriteLine("Running Imaging Cloud examples:");
                Console.WriteLine();

                // Update parameters of existing BMP image
                var bmpImage = new UpdateBmpImage(api);
                bmpImage.ModifyBmpFromStorage();
                bmpImage.ModifyBmpAndUploadToStorage();
                bmpImage.CreateModifiedBmpFromRequestBody();

                // Crop an existing image
                var cropImage = new CropImage(api);
                cropImage.CropImageFromStorage();
                cropImage.CropImageAndUploadToStorage();
                cropImage.CreateCroppedImageFromRequestBody();

                // Deskew an existing image
                var deskewImage = new DeskewImage(api);
                deskewImage.DeskewImageFromStorage();
                deskewImage.DeskewImageAndUploadToStorage();
                deskewImage.CreateDeskewedImageFromRequestBody();

                // grayscale an existing image
                var grayscaleImage = new GrayscaleImage(api);
                grayscaleImage.GrayscaleImageFromStorage();
                grayscaleImage.GrayscaleImageAndUploadToStorage();
                grayscaleImage.CreateGrayscaledImageFromRequestBody();

                // Process existing EMF imaging using given parameters
                var updateEmfImage = new UpdateEmfImage(api);
                updateEmfImage.ModifyEmfFromStorage();
                updateEmfImage.ModifyEmfAndUploadToStorage();
                updateEmfImage.CreateModifiedEmfFromRequestBody();

                // Export existing image to another format
                var exportImage = new ExportImage(api);
                exportImage.SaveImageAsFromStorage();
                exportImage.SaveImageAsAndUploadToStorage();
                exportImage.CreateSavedImageAsFromRequestBody();

                // Apply a filtering effect to an image
                var filterImage = new FilterImage(api);
                filterImage.FilterImageFromStorage();
                filterImage.FilterImageAndUploadToStorage();

                // Get properties of an image
                var imageProperties = new ImageProperties(api);
                imageProperties.GetImagePropertiesFromStorage();
                imageProperties.ExtractImagePropertiesFromRequestBody();

                // Resize an existing image
                var resizeImage = new ResizeImage(api);
                resizeImage.ResizeImageFromStorage();
                resizeImage.ResizeImageAndUploadToStorage();
                resizeImage.CreateResizedImageFromRequestBody();

                // Rotate and/or flip an existing image
                var rotateFlipImage = new RotateFlipImage(api);
                rotateFlipImage.RotateFlipImageFromStorage();
                rotateFlipImage.RotateFlipImageAndUploadToStorage();
                rotateFlipImage.CreateRotateFlippedImageFromRequestBody();

                // TIFF Frames
                var multiframeImage = new MultiframeImage(api);
                multiframeImage.GetImageFrameFromStorage();
                multiframeImage.GetImageFrameAndUploadToStorage();
                multiframeImage.CreateImageFrameFromRequestBody();
                multiframeImage.GetImageFrameRangeFromStorage();
                multiframeImage.GetImageFrameRangeAndUploadToStorage();
                multiframeImage.CreateImageFrameRangeFromRequestBody();
                multiframeImage.GetImageFramePropertiesFromStorage();
                multiframeImage.ExtractImageFramePropertiesFromRequestBody();

                // Update parameters of existing TIFF image
                var tiffImage = new TiffImage(api);
                tiffImage.ModifyTiffFromStorage();
                tiffImage.ModifyTiffAndUploadToStorage();
                tiffImage.CreateModifiedTiffFromRequestBody();
                tiffImage.ConvertTiffToFaxFromStorage();
                tiffImage.AppendTiffFromStorage();

                // Update parameters of existing GIF image
                var updateGifImage = new UpdateGifImage(api);
                updateGifImage.ModifyGifFromStorage();
                updateGifImage.ModifyGifAndUploadToStorage();
                updateGifImage.CreateModifiedGifFromRequestBody();

                // Perform scaling, cropping and flipping of an existing image in a single request
                var updateImage = new UpdateImage(api);
                updateImage.UpdateImageFromStorage();
                updateImage.UpdateImageAndUploadToStorage();
                updateImage.CreateUpdatedImageFromRequestBody();

                // Update parameters of existing JPEG2000 image
                var updateJpeg2000Image = new UpdateJpeg2000Image(api);
                updateJpeg2000Image.ModifyJpeg2000FromStorage();
                updateJpeg2000Image.ModifyJpeg2000AndUploadToStorage();
                updateJpeg2000Image.CreateModifiedJpeg2000FromRequestBody();

                // Update parameters of existing JPEG image
                var updateJpegImage = new UpdateJpegImage(api);
                updateJpegImage.ModifyJpegFromStorage();
                updateJpegImage.ModifyJpegAndUploadToStorage();
                updateJpegImage.CreateModifiedJpegFromRequestBody();

                // Update parameters of existing PSD image
                var updatePsdImage = new UpdatePsdImage(api);
                updatePsdImage.ModifyPsdFromStorage();
                updatePsdImage.ModifyPsdAndUploadToStorage();
                updatePsdImage.CreateModifiedPsdFromRequestBody();

                // Update parameters of existing WEBP image
                var webpImage = new UpdateWebPImage(api);
                webpImage.ModifyWebPFromStorage();
                webpImage.ModifyWebPAndUploadToStorage();
                webpImage.CreateModifiedWebPFromRequestBody();

                // Process existing WMF image using given parameters
                var wmfImage = new UpdateWmfImage(api);
                wmfImage.ModifyWmfFromStorage();
                wmfImage.ModifyWmfAndUploadToStorage();
                wmfImage.CreateModifiedWmfFromRequestBody();

                // AI APIs
                Console.WriteLine("Running AI examples:");
                Console.WriteLine();

                // Compare two images
                var compareImages = new CompareImages(api);
                compareImages.PrepareSearchContext();
                compareImages.CompareTwoImagesInCloud();
                compareImages.CompareLoadedImageToImageInCloud();
                compareImages.DeleteSearchContext();

                // Find Duplicate Images
                var findDuplicateImages = new FindDuplicateImages(api);
                findDuplicateImages.PrepareSearchContext();
                findDuplicateImages.FindImageDuplicates();
                findDuplicateImages.DeleteSearchContext();

                // Find Similar Images
                var findImages = new FindSimilarImages(api);
                findImages.PrepareSearchContext();
                findImages.FindImagesSimilar();
                findImages.FindImagesByTag();
                findImages.SearchImageFromWebSource();
                findImages.DeleteSearchContext();

                //object detection
                var objectDetection = new ObjectDetection(api);
                objectDetection.DetectObjectsImageFromStorage();
                objectDetection.DetectedObjectsImageFromRequestBody();
                objectDetection.VisualiizeDetectObjectsAndUploadToStorage();
                objectDetection.VisualizeDetectedObjectsImageFromRequestBody();

                // custom fonts
                var customFonts = new LoadCustomFonts(api);
                customFonts.UsingCustomFontsForVectorImageConversion();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something goes wrong: {ex}");
                Environment.Exit(1);
            }

            Environment.Exit(0);
        }
示例#5
0
        /// <summary>
        /// 比对图片
        /// </summary>
        private static void CompareImages()
        {
            ISample compareImage = new CompareImages();

            compareImage.Run();
        }