C#EmguCV错误"OpenCV:u!= 0&" [英] C# EmguCV error "OpenCV: u != 0"

查看:232
本文介绍了C#EmguCV错误"OpenCV:u!= 0&"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试匹配一些照片时,我一直收到此 OpenCV:u!= 0 错误.我的方法看起来像这样.ImageFile类具有一些变量.即使我要匹配一张照片,它也会这样做.Stacktrace正在:

I keep getting this OpenCV: u != 0 error when trying to match some photos. My method looks like this. ImageFile class has some variables. It does this even if I am trying to match one photo. Stacktrace being:

未处理的异常:Emgu.CV.Util.CvException:OpenCV:u!= 0

Unhandled Exception: Emgu.CV.Util.CvException: OpenCV: u != 0

在Emgu.CV.CvInvoke.CvErrorHandler(Int32状态,IntPtr函数名称,IntPtr errMsg,IntPtr文件名,Int32行,IntPtr用户数据)

at Emgu.CV.CvInvoke.CvErrorHandler(Int32 status, IntPtr funcName, IntPtr errMsg, IntPtr fileName, Int32 line, IntPtr userData)

在Emgu.CV.Features2D.Feature2DInvoke.CvFeature2DDetectAndCompute(IntPtr feature2D,IntPtr图像,IntPtr掩码,IntPtr关键点,IntPtr描述符,布尔useProvidedKeyPoints)

at Emgu.CV.Features2D.Feature2DInvoke.CvFeature2DDetectAndCompute(IntPtr feature2D, IntPtr image, IntPtr mask, IntPtr keypoints, IntPtr descriptors, Boolean useProvidedKeyPoints)

在Emgu.CV.Features2D.Feature2D.DetectAndCompute(IInputArray图像,IInputArray掩码,VectorOfKeyPoint键点,IOutputArray描述符,布尔useProvidedKeyPoints)

at Emgu.CV.Features2D.Feature2D.DetectAndCompute(IInputArray image, IInputArray mask, VectorOfKeyPoint keyPoints, IOutputArray descriptors, Boolean useProvidedKeyPoints)

public async Task<List<ImageFile>> BeginSearchAsync()
{
    var foundImageFiles = new List<ImageFile>();
    Mat img = CvInvoke.Imread(_imageFileToBeSearched.FileInfo.FullName, ImreadModes.AnyColor);

    var thredi = new Thread(() =>
    {
        foreach (var imageFile in _listOfSearchableImageFiles)
        {
            try
            {
                using (var tempImage = CvInvoke.Imread(imageFile.FileInfo.FullName, ImreadModes.AnyColor))
                {
                    var result = DrawMatches.Draw(tempImage, img, out long matchTime, out long score);
                    var window = new ResultWindow(result, score);
                    window.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error during matching file {imageFile.Name}");
                Console.WriteLine(ex.Message);
            }
        }
    });

    thredi.SetApartmentState(ApartmentState.STA);
    thredi.Start();
    return foundImageFiles;
}

推荐答案

该异常似乎表明应用占用了太多内存.就我而言,我似乎对图片的质量太好.将它们减少一半即可解决问题.

That exception seems to indicate that app is taking too much memory. In my case I just seemed to have too good quality for the pictures. Reducing them to half fixed the problem.

这篇关于C#EmguCV错误"OpenCV:u!= 0&"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆