CascadeClassifier.load() error in release only - c++

I want to ask about cascadeclassfier load doesn't work in release.
I using Microsoft Visual Studio 2010 and OpenCV 2.4.7.
my code:
CascadeClassifier cascade;
if(!cascade.load("D:/data/training.xml"))
{
printf("Error load XML!\n");
return -1;
}
Things i've tried so far:
Tried to specify the path manually using ""
Tried to use / or \ in the path
Tried to give user permission
Tried to call the xml without using absolute path
Tried to use many kind of codes i've found when searching this error
Tried to seperate the xml by creating a new folder for them
Additional Information:
Running in debug mode work 100% perfectly
Running in release while using visual studio trigger a break
Running using the exe created while building only show "Error load XML!"
i really confused right now, so i decided to ask..
Thanks before.

I've had similar problems when switch from Debug to Release Mode. I had copy config from Debug to Release and mistake at Linker > Input > Additional Dependencies. And I had fix this problem by using opencv_world320d.lib for Debug mode and opencv_world320.lib for Release mode.

Related

Error in opencv function in .exe file but not in debug nor release

One more time, I want to ask for your help after long and unfruitful researches.
I have developped an app using OpenCV which works very well is Visual Studio in debug and release mode.
I tried to deploy it, but i get a fatal error when I start the .exe. By using a log file and doing tests, I figured out the problem was in function cv::resize in the following code :
Mat logo = imread("lena.png");
cv::resize(logo, logo, Size(), 0.55, 0.55, INTER_CUBIC);
I found very weird that i can call cv::imread (and cv::Mat) without throwing exception but not resize.
If I try to run the .exe created by the compilation in release mode, i get the following errod code : 0xc000007b.
I read it could be a problem of compatibility between 32/64-bits dll, without being able to solve it. I try to build a 64-bits appplication. The path for opencv lib is define like this : C:\opencv\build\x64\vc14\lib
Thank you for your help,
Valentin B

Exit 1 when calling mono_jit_init

Hi, I try to embed mono in a c++ application on windows. I followed http://www.mono-project.com/docs/compiling-mono/windows/ and I have my headers, lib and dll built for win64.
I wrote a simple app that just calls
MonoDomain *domain;
domain = mono_jit_init("ConsoleApplication1.exe");
Everything builds and link find but when I run my program, I can break and step until the mono_jit_init call. Then the apps performs an exit1 and I can't see what's wrong.
I tried both release and debug.
Any ideas on how to find the issue? Properly embed mono?
Thanks, JNQ
Your application probably fails on loading Mono libraries.
You can use Process Monitor (https://learn.microsoft.com/en-us/sysinternals/downloads/procmon) to find out what exactly fails for you:
Run Process Monitor
Set Process Monitor filter to "[Process Name] [is] [Your process name, e.g. ConsoleApplication1.exe] then [Include]"
Run you program and lookup for "CreateFile" operations with "NAME NOT FOUND" Result and see Path column to find out what file is missing
In my case it was a failure on loading mono mscorlib.dll from lib\mono\4.5\mscorlib.dll so copying the files from the Mono installation to the path pointed by Process Monitor has helped.

Failed to use imwrite() in Qt Creator in Debug mode

I used imwrite() function in Qt Creator. I failed to run the code in Debug mode,while successfully in Release mode.
I wrote a test program.The followings is what I have done:
First to use OpenCV, I added the following code in .pro:
INCLUDEPATH+=D:\Work_Software\OpenCV3.1\opencv\build\include
LIBS+=D:\Work_Software\OpenCV3.1\opencv\build\x64\vc12\lib\*.lib
Then I added a Push Button. The slot function is:
void MainWindow::on_pushButton_clicked()
{
Mat img;
img=imread("F:\\My_Desktop\\foot1.jpg",0);
imwrite("F:\\My_Desktop\\result.jpg",img);
namedWindow("test");
imshow("test",img);
waitKey(0);
}
Finally, in Release mode, I can successfully read and write the image. However, failed to write in Debug mode. The error information is:
UPDATE
imread works in debug mode, for example, I change the slot function into:
void MainWindow::on_pushButton_clicked()
{
Mat img;
img=imread("F:\\My_Desktop\\foot1.jpg",0);
namedWindow("test");
imshow("test",img);
waitKey(0);
imwrite("F:\\My_Desktop\\result.jpg",img);
}
I can successfully load and imshow the image in Debug mode, but when I closed the windows, the same error happened.
The content of lib folder:
I have just seen a problem like mine similar problem , but it could not fix mine.
It happens because you included all library using *.lib command. In debug mode if you links with release libraries it fails. It works in release mode cause it links with release libs as it comes first due to string sort. See the image
Here 2411d.lib stands for debug library and 2411.lib stands for release library. I faced this issue and fixed separate linking in debug & release mode. You can either make 2 folders of debug and release libraries or you can mention the library names instead of *.lib.
[change the version for you]
Debug link: LIBS+=D:\Work_Software\OpenCV2.411\opencv\build\x64\vc12\lib\*‌​d.lib
Release link: LIBS+=D:\Work_Software\OpenCV2.411\opencv\build\x64\vc12\lib\*‌​2411.lib
OR
To separate folder See the images:
Folder stucture:
Debug Library folder:
Release Library folder:
UPDATE
If opencv is not built with qt properly please follow link
OpenCV dll and lib files are differ in terms of CPU architecture (32-64 bit) and Debug-Release mode. if you switch to Debug mode you must use dll and lib files for Debug mode (depends on CPU architecture).

OCCI app crashes when running in debug mode in Visual Studio 2005

I'm attempting to get a development environment up and running for developing applications with Oracle C++ Call Interface (OCCI) in Visual Studio 2005.
My system specs are:
OS: Windows 7, 64-bit
Oracle: 11g release 11.2.0.2, 32-bit
Instant Client: BasicLite and SDK version 11.2.0.4 32-bit
Visual Studio 2005 Professional Edition version 8.0 with 32-bit tools enabled
I've followed this guide by Mark Williams and I got the example running but only in release mode. When I switch to debug mode the app will build, but when I run it I get the following error:
Problem signature:
Problem Event Name: APPCRASH
Application Name: OCCITest.exe
Application Version: 0.0.0.0
Application Timestamp: 53f5dfdd
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.18229
The small example program that triggers this error is:
#include "employees.h"
using namespace std;
using namespace oracle::occi;
int main (void)
{
Employees *pEmployees = new Employees();
delete pEmployees;
return 0;
}
Employees::Employees()
{
user = "hr";
passwd = "hr";
db = "localhost:1521/service_name";
env = Environment::createEnvironment(Environment::DEFAULT);
try
{
con = env->createConnection(user, passwd, db);
}
catch (SQLException& ex)
{
cout << ex.getMessage();
exit(EXIT_FAILURE);
}
}
Employees::~Employees()
{
env->terminateConnection (con);
Environment::terminateEnvironment (env);
}
If I remove all calls to OCCI functionality the application doesn’t crash. That is, this program runs error-free:
#include "employees.h"
using namespace std;
using namespace oracle::occi;
int main (void)
{
Employees *pEmployees = new Employees();
delete pEmployees;
return 0;
}
Employees::Employees()
{
user = "hr";
passwd = "hr";
db = "localhost:1521/service_name";
cout<<"Look at me, I'm running"<<endl;
}
Employees::~Employees()
{}
In the guide Mark mentions that when running in debug mode, the linker should use the library file oraocci11d.lib. However, this file is not included in the Instant Client SDK version 11.2.0.4, so I’m using the input file oraocci11.lib for both the release and debug version.
I'm running out of ideas about how to proceed in solving this problem, and I would greatly appreciate any and all help.
If the Oracle DLL receives and/or passes objects such as std::string or any other object that either:
Manipulates the heap in any way, or
The objects could have differing internals between app and DLL,
then you have no choice but to use the correct library to link with. Otherwise you wind up with binary or heap incompatible objects being passed, which leads to what you're seeing now.
See here: http://docs.oracle.com/cd/E11882_01/appdev.112/e10764/install.htm#CBHGBBJI
The link above mentions both the debug import library and debug version of the DLL. Also this is stated at the link:
Applications that link to MSVCRTD.DLL, a debug version of Microsoft C-Runtime, /MDd compiler flag, should link with these specific OCCI libraries: oraocci11d.lib and oraocci11d.dll.
Since it took me quite some time to get the debug environment working I figured I'd answer my own question now that I did.
I got a variety of errors throughout the ordeal, but the error that I got most stuck on was an error saying:
'The application was unable to start correctly (0xc0150002).
Click OK to close the application.'
Also, I used http://www.dependencywalker.com which repeatedly told me that either oraocci11d.dll or a the following list of dll's could not be found.
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
However, what was really missing was for the executable to be able to find oci.dll. I'm just mentioning the errors in case someone else runs into these.
Here is what was needed to make it work:
First of all, the Instant Client does not contain the oraocci11d.lib or oraocci11d.dll, so it is necessary to install the full Oracle Client.
Next, the following must be added to the PATH:
C:\Program Files\Oracle\11.2.0\OCI\lib\MSVC\vc8
C:\Program Files\Oracle\11.2.0\BIN
In Visual Studio, select Tools -> Options, unfold 'Projects and Solutions' and select VC++ Directories. In 'Show directories for' under:
Include Files add C:\Program Files\Oracle\11.2.0\OCI\include
Library files add C:\Program Files\Oracle\11.2.0\OCI\lib\MSVC\vc8
In the property page for your project under Configuration Properties -> Linker select Input and under Additional Dependencies add oraocci11d.lib (or oraocci11.lib for release mode). Then select debug/release mode in the Configuration Manager
I have a related problem in that I am successfully using oraocci12d.dll/msvcr100d.dll, but this in turn is using oci.dll/msvcr100.dll. ie, oci.dll is not using the debug version of msvcr100.
My program seems to run okay, but any memory leak reporting disappears on exit.

Eclipse SDL build error: "The program specified in the launch configuration does not exist"

I've tried working some SDL on my set-up eclipse, and as I tried running it it gave me the following error:
'Launching SDL.exe' has encountered a problem.
The program specified in the launch configuration does not exist
I instantly went to another project to see if it builds, and it did. I also tried re-building, debugging the SDL project. I don't know if it's an error in code but just in case, this is the code:
#include "SDL/SDL.h"
#include <string>
#include <SDL/SDL_image.h>
SDL_Surface *load_image( std::string filename ) {
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load(filename.c_str());
if(loadedImage != NULL) {
optimizedImage = SDL_DisplayFormat(loadedImage);
SDL_FreeSurface(loadedImage);
}
return optimizedImage;
}
I've googled it, and there's a duplicate question on stackOverFlow here, however it has 0 answers, not even a comment. There are no answers on google regarding this problem, so if you'd answer it, you'd probably solve hours of headaches for more people.
I encountered the same problem with eclipse in Ubuntu. Spent 30 minutes and finally got it fixed as below:
Click Project -> Properties;
Select run/debug settings, and then the current configuration on the right pane, click edit;
In the c/c++ application textbox, select search project, and then click the binary you want to execute for the current project.
On my system, the previous problem is due to incorrect default file name --- the linker generates abinary.exe but in run configuration it is "abinary".
Such tiny (but time consuming) problems should have been fixed by Eclipse developers, if they got well paid as MS or apple developers. Alas, free software?
Right click on your project in the Project Explorer and select Debug As -> Local C/C++ Application.
Check to make sure you didn't accidentally hit a space first, when typing in the project name. Also, if on windows use CMD or Linux ls -al your workspace and look carefully at the columns of names. Try executing your .exe from the command line. If it's not there, well, look at your build output more closely! :-)
I'm using Eclipse Neon.
In my case I was copy pasting a code to understand enumerator, but the code was faulty. As I built the project, the binaries disappeared and it said:
the program file in launch configuration does not exist
Then I tried a simple hello world program and it still gave an error. The actual problem was that the src folder had both the files (I don't know how). When I deleted the other one it built and ran successfully. Hope this helped.