AForge.Net过滤器MonoTouch的替代品(AForge.Net Filters alte

2019-09-21 05:30发布

有什么选择? 我不能让它工作了MonoTouch的。 好像一些功能从AForge * .DLL的丢失。 现在,我期待在OpenCV的,但它只是太复杂,这样一个简单的问题。 不过还是很有意思:)

那么,有没有问题System.Drawing.Bitmap ,我从它建成github.com/mono/和它的工作。 但有相关AForge框架的错误。 当我尝试申请通过过滤器Bitmap Apply (Bitmap image)AForge.Imaging.Filters.BaseFilter我得到的错误:

错误CS0584:内部编译器错误:未找到方法:“AForge.Imaging.UnmanagedImage.CollectActivePixels”。 (CS0584)(PROJECTNAME)

此外,当我试图使用AForge.Imaging.Filters.SepiaInvert ,编译器无法找到他们:

错误CS0584:内部编译器错误:无法导入型AForge.Imaging.Filters.Sepia' from AForge.Imaging,版本= 2.2.4.0,文化=中性公钥= ba8ddea9676ca48b'(CS0584)(项目名称)

有趣的是, 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的,压缩)。

答: MonoDevelop的。 方法,从大会浏览器中可见未找到。 (CS0584)

文章来源: AForge.Net Filters alternatives for Monotouch