Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to detect page corners using openCV

I tried below code:

    IplImage* eig_image = 0;
    IplImage* temp_image = 0;

    // Create grayscale IplImage from UIImage
    IplImage *img_color = [self CreateIplImageFromUIImage:imageView.image];
    IplImage *img1 = cvCreateImage(cvGetSize(img_color), IPL_DEPTH_8U, 1);
    cvCvtColor(img_color, img1, CV_BGR2GRAY);
    cvReleaseImage(&img_color);

    if(img1==0) {
        printf("oh no!");
    }

    eig_image = cvCreateImage(cvGetSize(img1),IPL_DEPTH_32F, 1);
    temp_image = cvCreateImage(cvGetSize(img1),IPL_DEPTH_32F, 1);

    const int MAX_CORNERS = 100;
    CvPoint2D32f corners[MAX_CORNERS];
    int corner_count = MAX_CORNERS;
    double quality_level = 0.1;
    double min_distance = 1;
    int eig_block_size = 3;
    int use_harris = true;
    double k  = .4;

    cvGoodFeaturesToTrack(img1, eig_image, temp_image,corners,&corner_count,quality_level,min_distance,NULL,eig_block_size,use_harris,k);

    NSLog(@"corners %d",corner_count);

But got result as corners = 0

Can anyone help me with this issue.

How to detect page corners using openCV

I tried below code:

    IplImage* eig_image = 0;
    IplImage* temp_image = 0;

    // Create grayscale IplImage from UIImage
    IplImage *img_color = [self CreateIplImageFromUIImage:imageView.image];
    IplImage *img1 = cvCreateImage(cvGetSize(img_color), IPL_DEPTH_8U, 1);
    cvCvtColor(img_color, img1, CV_BGR2GRAY);
    cvReleaseImage(&img_color);

    if(img1==0) {
        printf("oh no!");
    }

    eig_image = cvCreateImage(cvGetSize(img1),IPL_DEPTH_32F, 1);
    temp_image = cvCreateImage(cvGetSize(img1),IPL_DEPTH_32F, 1);

    const int MAX_CORNERS = 100;
    CvPoint2D32f corners[MAX_CORNERS];
    int corner_count = MAX_CORNERS;
    double quality_level = 0.1;
    double min_distance = 1;
    int eig_block_size = 3;
    int use_harris = true;
    double k  = .4;

    cvGoodFeaturesToTrack(img1, eig_image, temp_image,corners,&corner_count,quality_level,min_distance,NULL,eig_block_size,use_harris,k);

    NSLog(@"corners %d",corner_count);

But got result as : corners = 0

Can anyone help me with this issue.