Here is the thing. I was re-writing my OpenCV code on Qt framework these days, and the code runs well on the Visual Studio 2013, but when I run it on the Qt, something weird happend.
To simplify the problem, I write another code to do experiment, and expectedly, the problem still remains.
Here is the code,
#include <iostream>
#include <highgui.hpp>
#include <core.hpp>
#include <cv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat view, viewGray;
vector<Point2f> pointBuf;
Size boardSize;
boardSize.width = 7; boardSize.height = 9;
view = imread("G:\\C++\\OpenCV\\OpenCV\\left1.jpg", 1);
cout << pointBuf.size() << endl;
cout << boardSize << endl;
cvtColor(view, viewGray, COLOR_BGR2GRAY);
bool found = findChessboardCorners(view, boardSize, pointBuf, \
CV_CALIB_CB_ADAPTIVE_THRESH | \
CV_CALIB_CB_FAST_CHECK | \
CV_CALIB_CB_NORMALIZE_IMAGE);
cout << pointBuf.size() << endl;
cout << found << endl;
namedWindow("show", CV_WINDOW_NORMAL);
imshow("show", view);
waitKey(0);
return 0;
}
when I run it on Visual Studio, everything is ok. The debug results are as follow.
Debug info on VS2013:
The size of pointBuf before the line bool found = findChessboardCorners(...)
is 0 , and then it turns into 63 after that line.
But when I run it on Qt, the debug result turns into very ridiculous,
The code before namedWindow("show", CV_WINDOW_NORMAL);
runs without any warning but get a different result, the size of pointBuf before the line bool found = findChessboardCorners(...)
is also 0, but it turns into a very huge number after that line, which is 4294044375.
but after namedWindow("show", CV_WINDOW_NORMAL);
, another problem occurs,
:-1: error: Exception at 0x778a768b, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)
and the whole debug info is as follow,
Debug info on Qt:
OS: windows 10 64-bit
Qt Vision: Qt5.6.0 with MSVC 2013
Visual Studio Vision: Visual Studio 2013.
OpenCV Vision: OpenCV3.0
update: I intialized some variables , and the problem is still there.
update 2: @Miki think that I am using the wrong OpenCV libs, (e.g.,using debug libs in release), so I give out all my configuration information as follow, hope someone can do me a favor.
QT += core
QT -= gui
CONFIG += c++11
TARGET = testApp
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH +=F:\opencv\build\include \
F:\opencv\build\include\opencv \
F:\opencv\build\include\opencv2
LIBS +=F:\opencv\build\x86\vc12\lib\opencv_ts300.lib \
F:\opencv\build\x86\vc12\lib\opencv_ts300d.lib \
F:\opencv\build\x86\vc12\lib\opencv_world300.lib \
F:\opencv\build\x86\vc12\lib\opencv_world300d.lib
update3: I re-compile the opencv libraries, and then do the same test as above, this time I get size of pointBuf is 1638 not 4294044375. So I am sure that the problem comes from the OpenCV itself.
update4: well, this problem has been solved by myself. I changed the opencv vision from 3.0 to 2.4.12, then the whole world calmed down. So I was right, the problem comes from opencv itself.
update5: @Miki was right , I did use the wrong libs. I forgot clear the project first yesterday, that's the reason that I did what @Miki told me but it dosen't work. Thx @Miki