Reputation: 537
I am trying to detect the corners of a chessboard image. I have tried using goodFeaturesToTrack and findChessboardCorners but they are both failing in the same way. They corner vector returned seems to be null. (i.e. size is -2948392...memory error type of stuff).
gray = imread("C:/Users/Wesley/Desktop/New folder/cb.png",0);
// Parameters for Shi-Tomasi algorithm
std::vector<cv::Point2f> corners;
double qualityLevel = 0.1;
double minDistance = 10;
int blockSize = 3;
bool useHarrisDetector = false;
double k = 0.04;
int maxCorners = 30;
Mat copy;
copy = gray.clone();
// Apply corner detection
goodFeaturesToTrack(gray,
corners,
maxCorners,
qualityLevel,
minDistance,
Mat(),
blockSize,
useHarrisDetector,
k );
int r = 4;
for( int i = 0; i < corners.size(); i++ )
{ circle( copy, corners[i], r, Scalar(255, 255,255), -1, 8, 0 ); }
// Show what you got
imshow( "source_window", copy );
It must be something I am doing wrong. It crashes as soon as corners.size() is called due to a memory access violation. This is in Qt if it makes any difference.
Hopefully someone can point me in the right direction!
Upvotes: 0
Views: 339
Reputation: 20160
Please check that you aren't compiling in release mode but linking against debug mode or vice versa.
OpenCV gives you the strangest behaviour if you link against the wrong libraries.
Upvotes: 2