private void ProcessImage(ImageProcessingMethod methodToExecute, Bitmap b) { m_Undo = (Bitmap)m_Bitmap.Clone(); if (methodToExecute(b)) { this.Invalidate(); } }
public void LoadFile_FileNameIsEmpty_ThrowExceptation() { // Arrange string fileName = string.Empty; var img = new ImageProcessingMethod(new ImageProcessing()); // Assert Assert.Throws <ArgumentException>(() => img.LoadFile(fileName)); }
public void SaveImage_FileNameIsEmpty_ReturnFalse() { // Arrange string fileName = string.Empty; Image image = null; ImageProcessingMethod img = new ImageProcessingMethod(new ImageProcessing()); // Assert Assert.False(img.SaveImage(image, fileName)); }
public void ToMainColorAsync_ImageIsNull_ReturnNull() { // Arrange var img = new ImageProcessingMethod(new ImageProcessing()); // Act var result = img.ToMainColorsAsync(null); // Assert Assert.Null(result); }
public void SaveImage_FileIsCorrect_ReturnTrue() { // Arrange string fileName = "./Images/test2_testFact.jpg"; Image image = Image.FromFile("./Images/test2.jpg"); ImageProcessingMethod img = new ImageProcessingMethod(new ImageProcessing()); // Assert Assert.True(img.SaveImage(image, fileName)); }
public void ToMainColorAsync_CorrectImage_ReturnNotNull() { // Arrange string fileName = "./Images/test2.jpg"; var img = new ImageProcessingMethod(new ImageProcessing()); var image = img.LoadFile(fileName); // Act var result = img.ToMainColorsAsync(image); // Assert Assert.NotNull(result); }
public void LoadFile_CorrectFileName_ResultNotEmpty() { // Arrange string fileName = "./Images/test2.jpg"; var img = new ImageProcessingMethod(new ImageProcessing()); // Act var result = img.LoadFile(fileName); // Assert Assert.NotNull(result); }
/** * Create a 'Configuration' wrapper object. * * @param algorithm * @return returns a 'Configuration' wrapper object asynchronously */ private IAsyncAction CreateConfiguration(ImageProcessingMethod processingMethod) { return(Task.Run(() => { this.configuration = new CW.Configuration(); // Create algorithms CW.FeatureMatching feature = new CW.FeatureMatching(CW.FeatureDetector.BRISK, CW.DescriptorMatcherType.BRUTEFORCE_HAMMING); CW.LSH lsh = new CW.LSH(); CW.ShapeDetection polygonDetection = new CW.ShapeDetection(); CW.ShapeDetection quadDetection = new CW.ShapeDetection(4, 4, "Quad"); // Configure image processing CW.MatchRecognition matchRecognition = new CW.MatchRecognition(feature, CW.Scaling.SCALE_640x360); CW.HashRecognition hashRecognition = new CW.HashRecognition(polygonDetection, lsh); CW.HybridRecognition hybridRecognition = new CW.HybridRecognition(hashRecognition, feature, 50); CW.ObjectDetection objectDetection = new CW.ObjectDetection(quadDetection); // Set callback methods (result image should have an alpha channel (required for WritableBitmap)) this.configuration.setResultCallback(this.ResultCallback, CW.ColorFormat.BGRA); this.configuration.setErrorCallback(this.ErrorCallback); // Set number of frames to skip this.configuration.setSkipFrame(0); // Set image buffer this.configuration.setImageBuffer(5); // Add source to configuaration CW.ImageStream stream = new CW.ImageStream(30); this.configuration.setSource(stream); // Create image models string model0 = this.assets.Path + "\\poster_left.jpg"; string model1 = this.assets.Path + "\\poster_right.jpg"; matchRecognition.addModel(new CW.FeatureMatchingModel(model0, 0)); matchRecognition.addModel(new CW.FeatureMatchingModel(model1, 1)); hashRecognition.addModel(model0, 0); hashRecognition.addModel(model1, 1); hybridRecognition.addModel(model0, 0); hybridRecognition.addModel(model1, 1); // Choose processing method switch (processingMethod) { case ImageProcessingMethod.FEATUE_MATCHING: this.configuration.setProcessing(matchRecognition); break; case ImageProcessingMethod.IMAGE_HASHING: this.configuration.setProcessing(hashRecognition); break; case ImageProcessingMethod.HYBRID_MATCHING: this.configuration.setProcessing(hybridRecognition); break; case ImageProcessingMethod.SHAPE_DETECTION: this.configuration.setProcessing(objectDetection); break; default: throw new Exception("Image processing method not found."); } }).AsAsyncAction()); }