AForge.Net过滤Monotouch的替代品

有什么选择吗? 我不能让Monotouch工作。 好像AForge * .dll中缺少一些function。 现在,我正在研究OpenCV,但这对于这么简单的问题来说太复杂了。 但还是很有意思:)

嗯, System.Drawing.Bitmap没有问题,我是从github.com/mono/构建的 ,它有效。 但是与AForge框架有关的错误。 当我尝试通过AForge.Imaging.Filters.BaseFilter Bitmap Apply (Bitmap image)应用filter时,我收到错误:

错误CS0584:内部编译器错误:找不到方法:’AForge.Imaging.UnmanagedImage.CollectActivePixels’。 (CS0584)(projectName)

此外,当我尝试使用AForge.Imaging.Filters.SepiaInvert ,编译器找不到它们:

错误CS0584:内部编译器错误:无法AForge.Imaging.Filters.Sepia' from AForge.Imaging,Version = 2.2.4.0,Culture = neutral,PublicKeyToken = ba8ddea9676ca48b’(CS0584)(projectName)导入类型AForge.Imaging.Filters.Sepia' from

有趣的是, AForge.Imaging.Filters.Grayscale找到了。

以下是产生这些错误的代码:

这个产生“ 无法导入类型 ”错误:

 partial void showFilters (MonoTouch.Foundation.NSObject sender) { UIActionSheet sheet = new UIActionSheet ("Filters"); // @TODO: I'll hardcode filters for now, but in future it should be refactored out. sheet.AddButton ("Grayscale"); sheet.AddButton ("Sepia"); sheet.AddButton ("Invert"); sheet.Clicked += (sndr, e) => { var ev = (UIButtonEventArgs)e; switch (ev.ButtonIndex) { case 0: imageView.Image = ImageProcessor.process (imageView.Image, new Grayscale(0.2125, 0.7154, 0.0721)); break; case 1: imageView.Image = ImageProcessor.process (imageView.Image, new Sepia()); break; case 2: imageView.Image = ImageProcessor.process (imageView.Image, new Invert()); break; } imageView.Image.SaveToPhotosAlbum((image, error) => { var o = image as UIImage; Console.WriteLine("error:" + error); }); }; sheet.ShowInView (this.View); } 

前3个函数产生“ 找不到方法:’AForge.Imaging.UnmanagedImage.CollectActivePixels’。:

  #region methods static public Bitmap process (String fileName, IFilter filter) { if (File.Exists (fileName)) { Bitmap bitmap = Bitmap.FromFile (fileName); Bitmap image = (Bitmap) filter.Apply (bitmap); return image; } else { throw (new FileNotFoundException()); } } static public Bitmap process (String fileName, FiltersSequence seq) { if (File.Exists (fileName)) { Bitmap image = Bitmap.FromFile (fileName); image = seq.Apply (image); return image; } else { throw (new FileNotFoundException()); } } #region iOS static public UIImage process (UIImage capturedImage, IFilter filter) { Bitmap bitmap = getBitmapFromUIImage (capturedImage); Bitmap image = (Bitmap) filter.Apply (bitmap); UIImage result = getUIImageFromBitmap (image); return result; } static public Bitmap getBitmapFromUIImage (UIImage capturedImage) { NSData imageData = capturedImage.AsPNG(); Byte[] byteArray = new Byte[imageData.Length]; System.Runtime.InteropServices.Marshal.Copy (imageData.Bytes, byteArray, 0, Convert.ToInt32 (imageData.Length)); MemoryStream stream = new MemoryStream (byteArray); Bitmap bitmap = new Bitmap (stream, false); return bitmap; } static public UIImage getUIImageFromBitmap (Bitmap bitmap) { Byte[] byteArray; MemoryStream stream = new MemoryStream(); bitmap.Save(stream); stream.Close(); byteArray = stream.ToArray(); NSData imageData = NSData.FromArray(byteArray); return UIImage.LoadFromData(imageData); } #endregion iOS #endregion methods } 

以及完整的错误列表:

 Error CS0584: Internal compiler error: Could not import type `AForge.Imaging.Filters.Sepia' from `AForge.Imaging, Version=2.2.4.0, Culture=neutral, PublicKeyToken=ba8ddea9676ca48b' (CS0584) (tryingImageProcessing) Error CS0584: Internal compiler error: Could not import type `AForge.Imaging.Filters.Invert' from `AForge.Imaging, Version=2.2.4.0, Culture=neutral, PublicKeyToken=ba8ddea9676ca48b' (CS0584) (tryingImageProcessing) Error CS0584: Internal compiler error: Method not found: 'AForge.Imaging.UnmanagedImage.CollectActivePixels'. (CS0584) (tryingImageProcessing) Error CS0266: Cannot implicitly convert type `object' to `System.Drawing.Bitmap'. An explicit conversion exists (are you missing a cast?) (CS0266) (tryingImageProcessing) 

我没有说出最后一个错误,因为它很容易修复,但我无法理解为什么它会出现。 它哭了:

 Bitmap image = ((BaseFilter) filter).Apply (bitmap); 

我使用的每一行都Apply

这是项目本身(Monodevelop,zipped)。

答案: Monodevelop。 从Assembly Browser中找不到的方法。 (CS0584)

Interesting Posts