OpenCV. cvFnName() works, but cv::FunName() doesn't work
- by Innuendo
I'm using OpenCV to write a plugin for a simulator. I've made an OpenCV project (single - not a plugin) and it works fine. When I added OpenCV libs to the plugin project, I added all libs required. Visual Studio 2010 doesn't highlight any code line with red. All looks fine and compiles fine.
But in execution, the program halts with a Runtime Error on any cv::function. For example: cv::imread, or cv::imwrite. But if I replace them with cvLoadImage() and cvSaveImage(), it works fine.
Why does this happen? I don't want to rewrite the whole script in old-api-style (cvFnName). It means I should change all Mat objects to IplImages, and so on.
UPDATE:
// preparing template
ifstream ifile(tmplfilename);
if ( !FILE_LOADED && ifile ) {
// loading template file
Mat tmpl = cv::imread(tmplfilename, 1); // << here occurs error
FILE_LOADED = true;
}
Mat src;
Bmp2Mat(hDC, hBitmap, src);
TargetDetector detector(src, tmpl);
detector.detectTarget();
If I change to:
if ( !FILE_LOADED && ifile ) {
IplImage* tmpl = 0;
tmpl = cvLoadImage(tmplfilename, 1); // no error occurs
}
And then no error occurs.
Early it displayed some Runtime Error. Now, I wanted to copy exact message and it just crashes the application (simulator, what I am pluginning). It displays window error - to kill process or no. (I can't show exact message, because I'm using russian windows now)