// In an outer scope, you might have... IplImage* draw_image = cvCreateImage(cvSize (640,480), IPL_DEPTH_8U, 3); IplImage* warp_image = cvCreateImage(cvSize (640,480), IPL_DEPTH_8U, 3); IplImage* gs_image = cvCreateImage(cvSize (640,480), IPL_DEPTH_8U, 1); IplImage* corner_image = cvCreateImage(cvSize (640,480), IPL_DEPTH_32F, 1); float thresh = 1.5; int block_size = 7; int aperture_size = 3; double k = 0.04; // I used key presses to change the parameters above to reasonable values... // within a processing loop, then, you could use... // get draw_image from a camera or a file... // convert to grayscale cvCvtColor( draw_image, gs_image, CV_RGB2GRAY ); // get Harris corners! cvCornerHarris( gs_image, corner_image, block_size, aperture_size, k ); // find min and max for scaling... double min_val = 1.0e9; double max_val = -1.0; CvPoint min_loc; CvPoint max_loc; cvMinMaxLoc( corner_image, &min_val, &max_val, &min_loc, &max_loc, NULL ); // NULL mask // scale the corner_image to [0,1] double scale_factor = 1.0/(max_val - min_val); double shift_amt = fabs( scale_factor * min_val ); cvConvertScale( corner_image, corner_image, scale_factor, shift_amt ); // now from 0 to 1 // make sure this works... //cvMinMaxLoc( corner_image, &min_val, &max_val, &min_loc, &max_loc, NULL ); // it checks out... // let's see it... cvShowImage(WINDOW_NAME, corner_image); // then we can threshold... int H = corner_image->height; int W = corner_image->width; IplImage* img = corner_image; for (int row=1 ; rowimageData + img->widthStep*row)); float px_val = px[col]; // check for local max in a 3x3 square... // we'll leave this to you... // here, we'll just check the threshold if (px_val > thresh) { px[col] = 1.0; } else { px[col] = 0.0; } } } // we could show this instead... //cvShowImage(WINDOW_NAME, corner_image);