harris corner detection

asked 2017-01-03 09:46:16 -0600

pep92 gravatar image

updated 2017-01-03 09:52:56 -0600

berak gravatar image

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);
}
edit retag flag offensive close merge delete

Comments

Your code works fine for me. Can you get the call stack when the problem occurse? The assembly code is not particularly useful.

Tetragramm gravatar imageTetragramm ( 2017-01-03 18:59:14 -0600 )edit

Thanks I figured out using this code

gray=cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 1); cvCvtColor( src, gray, CV_BGR2GRAY );

    dst=cvCreateImage(cvSize(w,h), IPL_DEPTH_32F, 1);
    dst_norm=cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 1);
    dst_norm_scaled=cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 1);
    dst_norm_scaled_color=cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 3);
    // Extracting Corners
    cvCornerHarris( gray, dst, 15, 9, 0.05);
    // Normalizing
    cvNormalize( dst, dst_norm, 0, 255, NORM_MINMAX );
    cvConvertScaleAbs( dst_norm, dst_norm_scaled );
    cvCvtColor( dst_norm_scaled, dst_norm_scaled_color, CV_GRAY2RGB );
pep92 gravatar imagepep92 ( 2017-01-04 15:55:16 -0600 )edit
1

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.

Tetragramm gravatar imageTetragramm ( 2017-01-04 18:05:24 -0600 )edit