ucrtbase.dll:无效参数传递给认为无效参数致命的函数 [英] ucrtbase.dll: An invalid parameter was passed to a function that considers invalid parameters fatal

查看:974
本文介绍了ucrtbase.dll:无效参数传递给认为无效参数致命的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用OpenCV进行个人项目,并且在程序执行过程中遇到一些问题.实施了AKAZE + BOW识别器(对于我的问题而言,它似乎还不能很好地工作),我想尝试SIFT(并最终实现SURF)的实现.

I'm currently working on a personal project with OpenCV and I have a few issues during the execution of the program. After implementing an AKAZE + BOW recognizer (which didn't seem to work well enough for my problem) I wanted to try out a SIFT (and eventually SURF) implementation.

对于我的项目,我正在以下

For my project I'm following this one found on github and I'm using VS2015 (community) and OpenCV 2.4.13 over Windows 10.

标题中所述,我遇到的问题在于ucrtbase.dll,该文件在执行过程中获取了无效参数(如果我正确读取了其他线程,则dll应该是Windows 10中的OS库).当for cicle移至第二次迭代时(也就是当它应该获取BOW训练的另一幅图像的特征时),即在执行停止并且标题中出现错误时,就会出现问题.

The issue I'm having, as stated in the title, lies with the ucrtbase.dll which gets an invalid parameter during execution (if I read other threads correctly the dll should be an OS library in Windows 10). The problem arises when the for cicle moves onto the second iteration (aka when it's supposed to get the features of another image for the BOW training), this is when the execution stops and the error in the title appears.

我尝试了各种方法(例如,为检测器/提取器使用不同的构造函数或注释了部分代码),并且在调试会话期间,错误似乎是由检测功能引起的,但我不确定为什么(也,如下面的代码所述,注释了detect函数及其后的函数以解决该问题.

I tried various things (eg. using different constructors for the detector/extractor or commenting part of the code) and during the debug session it seems that the error is caused by the detect function but I'm not sure why (also, as stated in the code below, commenting the detect function and those following it fixes the problem).

drawKeypoints函数(在另一项测试中使用)似乎在正确绘制关键点(这应该意味着detect函数正常工作).

The drawKeypoints function (used in another test) seems to be drawing the keypoints correctly (which should mean the detect function is working correctly).

在下面,您可以找到出现错误的代码段:

Below you can find the snippet that's giving the error:

int main(int argc, char ** argv)
{

    const int nimages = 4;
    const int nclusters = 2;

    const char *datapath = "./database";

    SiftFeatureDetector detector(400);
    SiftDescriptorExtractor extractor;
    Ptr<BOWTrainer> bow_train = makePtr<BOWKMeansTrainer>(nclusters);

    for (int i = 0; i<nimages; i++)
    {

        Mat im, feat;
        std::vector<KeyPoint> kp;

        // read an image from the database
        im = cv::imread(format("%s/%d.png", datapath, i + 1), 1);

        // detect keypoints
        detector.detect(im, kp); // commenting from here avoids the error

        // extract features
        extractor.compute(im, kp, feat);

        // add features for bow training
        bow_train->add(feat);

    }

    /* more stuff here */
}

如果还有其他需要了解的问题,请告诉我.

Tell me if there's anything else you need to know to understand the problem.

预先感谢您可以给我的任何帮助/建议.

Thanks in advance for any help/advice you can give me.

我尝试删除所有用于cicle的程序,程序设法正确执行所有功能,但从main返回时仍然给出ucrtbase.dll错误.我在VS调试期间注意到的另一件事是,调试器必须在cicles期间或程序结束时必须释放内存(使用该dll)时,才会生成异常.

I tried removing all for cicles and the program manages to reach the end executing all functions correctly but it's still giving the ucrtbase.dll error when returning from main. Another thing I've noticed during VS debug is that the debugger generates an exception when it has to deallocate memory (using that dll), either during for cicles or at the end of the program.

我想这里的调试器可以解决该问题,但我并没有真正了解该dll的问题,如果有人有时间,那么任何帮助将不胜感激.

I guess the debugger here has the solution but I don't really get what's the problem with that dll, any help will be really appreciated if anyone has time to spare.

经过几天的测试,似乎错误是由于以下原因导致的:

After a few days of testing it seems the error is coming from the deallocation of:

std :: vector< cv :: KeyPoint>

std::vector< cv::KeyPoint >

如果KeyPoint向量被实例化并且仅在程序结束时销毁,则计算工作正常,并且最后出现dll错误(这很烦人,但我可以应对快速测试).

If KeyPoint vectors are instantiated and only destroyed when the program ends, the computation works just fine and there's the dll error at end (which is annoying but for quick tests I can cope with).

问题是我想创建使用这些向量的函数,而不必将它们作为参数传递.由于解除分配似乎是个问题,因此在每次调用所述函数后都没有程序崩溃,我无法做到这一点.我也尝试过在向量上使用clear()和swap(),但这也不起作用.

The issue is I'd like to create functions that make use of those vectors without having to pass them as arguments. Since the deallocation seems to be the problem I can't do that without having the program crash after each call to said functions. I have also tried using clear() and swap() on the vector but that didn't work either.

在继续编码的过程中,我会不断尝试解决这个问题,但对您的帮助/见解将不胜感激.

I'll keep trying to figure this out as I keep coding but any help/insight would really be appreciated.

推荐答案

一段时间后,我想我已经知道了.

After some time I guess I figured this out.

似乎问题出在VS2015编译器上:OpenCV 2.4.13在该版本的VS上存在一些问题,这可能是因为只有一个vc12文件夹而不是应该与VS2015一起使用的vc14(基本上,兼容性不完全保证).

It seems the issue was with VS2015 compiler: OpenCV 2.4.13 has some issues with that version of VS and that's probably because there's only a vc12 folder instead of the vc14 that's supposed to work with VS2015 (basically the compability is not fully guaranteed).

转到OpenCV3.1构建(带有额外的模块)后,程序正在运行,而不会引发任何异常.

After moving to the OpenCV3.1 build (with the extra modules) the program is running without throwing any exception.

这篇关于ucrtbase.dll:无效参数传递给认为无效参数致命的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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