简体   繁体   English

如何在 Xamarin Forsm 中打开图像并将其与 EmguCv/OpenCvSharp 一起使用?

[英]How to open an image and use it with EmguCv/OpenCvSharp in Xamarin Forsm?

I'm developing an app in Xamarin Forms, I need to process images, but I could not do it either OpenCvSharp or EmguCv.我正在 Xamarin Forms 中开发一个应用程序,我需要处理图像,但我无法做到 OpenCvSharp 或 EmguCv。

When I try to open the image sending the path, it does not work and crashes:当我尝试打开发送路径的图像时,它不起作用并崩溃:

Here is my code:这是我的代码:

var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
            {
                CompressionQuality = 100,
                PhotoSize = PhotoSize.Large
            });    
Mat OriginalImage = new Mat(file.Path, ImreadModes.AnyColor);

When I run my app, does not work.当我运行我的应用程序时,它不起作用。

Do you know any solution or any tutorial to follow?你知道任何解决方案或任何教程吗?

在此处输入图片说明

I'm not really familar with OpenCvSharp, but if you want to do it in Emgucv, you can use the following code.我对OpenCvSharp不是很熟悉,但是如果你想在Emgucv中做,可以使用下面的代码。

//Create a string to hold the file location
string fileLocation;

//Create an openfiledialog object to select a photo
OpenFileDialog dialog = new OpenFileDialog
{
    InitialDirectory = Directory.GetParent(Directory.GetParent
        (Environment.CurrentDirectory).ToString()).ToString(),
    Title = "Browse Images",

    CheckFileExists = true,
    CheckPathExists = true,

    FilterIndex = 2,
    RestoreDirectory = true,

    ReadOnlyChecked = true,
    ShowReadOnly = true
};

if (dialog.ShowDialog() == true)
{
    fileLocation = dialog.FileName;

    Mat input = CvInvoke.Imread(fileLocation, ImreadModes.AnyColor);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM