harris corner detection
I'm using this code for corner detection but I'm getting an exception not handled interrupt point at this operation:
mov ecx,dword ptr [esp+54h]
I can't find what I'm doing wrong.
Here is the code
using namespace cv;
using namespace std;
int thresh = 200;
int main( )
{
Mat src, gray;
// Load source image and convert it to gray
src = imread( "lena.jpg", 1 );
cvtColor( src, gray, CV_BGR2GRAY );
Mat dst, dst_norm, dst_norm_scaled;
dst = Mat::zeros( src.size(), CV_32FC1 );
// Detecting corners
cornerHarris( gray, dst, 7, 5, 0.05, BORDER_DEFAULT );
// Normalizing
normalize( dst, dst_norm, 0, 255, NORM_MINMAX, CV_32FC1, Mat() );
convertScaleAbs( dst_norm, dst_norm_scaled );
// Drawing a circle around corners
for( int j = 0; j < dst_norm.rows ; j++ )
{ for( int i = 0; i < dst_norm.cols; i++ )
{
if( (int) dst_norm.at<float>(j,i) > thresh )
{
circle( dst_norm_scaled, Point( i, j ), 5, Scalar(0), 2, 8, 0 );
}
}
}
// Showing the result
namedWindow( "corners_window", CV_WINDOW_AUTOSIZE );
imshow( "corners_window", dst_norm_scaled );
waitKey(0);
return(0);
}
Your code works fine for me. Can you get the call stack when the problem occurse? The assembly code is not particularly useful.
Thanks I figured out using this code
gray=cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 1); cvCvtColor( src, gray, CV_BGR2GRAY );
I'm sorry, but you shouldn't be using the C interface at all. It's very old and not supported. I should also point out that at no point in what you just posted do you actually load an image.
As I said, the code in your original question works just fine and appears to be correct. Did you actually have an image named lena.jpg to load? You could see that problem if there was no image named that.