Simple OpenCV command works in Debug mode but not Release mode

后端 未结 4 441
时光说笑
时光说笑 2021-01-11 13:20

I am trying to load in a training xml file with CascadeClassifier::load(), and it works just fine in Debug mode, but in Release mode I get a runtime error.

相关标签:
4条回答
  • 2021-01-11 13:30

    I believe your error is in the 'loading' of the XML file and your 'working directory' setting in your project settings.

    If you goto the Properties window of your project, make sure the 'Working Directory' in "Debugging" Options is correct. Change the 'Configuration' (between Debug and Release) and you should be able to compare.

    You will sometimes get this error when you're trying to read a file that doesn't exist. Using local paths which being in the 'wrong' working directory is usually the culprit when it works in one configuration and not another.

    EDIT:

    Does that file exist and is it proper XML?

    0 讨论(0)
  • 2021-01-11 13:33

    make sure you're linking to openCV's release dlls when running in release mode. I've had similar problems when I tried to load files with mixed release and debug dlls.

    See this post.

    0 讨论(0)
  • 2021-01-11 13:45

    No guesses on why your load line would cause an access violation only for release build. So, the next step is to instrument your OpenCV release binaries with logging, or printfs, or whatever works for you. This type of debugging works in this scenario since you have the source for OpenCV and the ability to recompile with VS2010.

    0 讨论(0)
  • 2021-01-11 13:46

    This is quite strange. Check your options for debug and release version, be sure that you are using the correct version of the libraries.

    I tried running the code on a project of mine, and works fine both in debug and release version, with opencv 2.3.1

    Try adding these lines of code to another project, with release version working and where you already use opencv. If it works, then the problem is in the configuration settings.

    0 讨论(0)
提交回复
热议问题