分配中的OpenCV不兼容类型

时间:2013-07-10 15:39:33

标签: c opencv iplimage

我的代码给了我这个错误,我不明白是什么问题。 有人能解释一下这是什么问题吗?谢谢!

这是错误代码:

circleDetection.c:133: error: incompatible types in assignment of ‘IplImage*’ to ‘IplImage* [(((long unsigned int)(((long int)cnt) - 1)) + 1u)]’

这是提供错误的文件的一部分:

void mainCircleDetection( IplImage *src )
{
    IplImage *img = cvCloneImage( src );

    if( !img ){
        printf("Image not loaded. EXITING...\n");
        exit( -1 );
    }

    IplImage *singleChannel = getSingleChannel( img );

    CvMemStorage *storage = cvCreateMemStorage(0);

    CvSeq *circlesStorage = findCircles( singleChannel );

    IplImage *imgCircles = drawCircles( img, circlesStorage );

    cvNamedWindow( "Detected circles", 1 );
    cvShowImage( "Detected circles", imgCircles );

    cvWaitKey( 0 );

    int cnt = circlesStorage->total;

    IplImage *circlesROI[ cnt ];

    circlesROI = getCircleROI( img, circlesStorage );

    cvDestroyAllWindows();

}

给出错误的行是 circlesROI = getCircleROI(img,circlesStorage);

这是另一个.c文件中的函数getCircleROI

IplImage *getCircleROI( IplImage *src, CvSeq *circles){

    IplImage *img = cvCloneImage( src );

    int cnt = circles->total;

    IplImage *circlesROI[ circles->total ];

    for (int i = 0; i < cnt; i++)
    {

        float *p = (float *)cvGetSeqElem( circles, i );
        CvPoint center = cvPoint( cvRound(p[0]), cvRound(p[1]) );
        int radius = (int)cvRound( p[2] );

        //void cvSetImageROI(IplImage* image, CvRect rect)
        //inline CvRect cvRect( int x, int y, int width, int height );
        cvSetImageROI( img, cvRect( center.x - radius, center.y - radius, 
            radius*2, radius*2) );

        //IplImage *mask = cvCreateImage( cvSize(radius*2, radius*2), img->depth, 1 );
        //cvZero( mask );

        //cvDrawCircle( mask, cvPoint( radius, radius), radius, cvScalarAll( 255 ), CV_FILLED );

        IplImage *res = cvCreateImage( cvGetSize(img), img->depth, 3);
        IplImage *roi = getSingleChannel( res );
        //prepare the ROI image
        cvZero( roi );
        cvZero( res );

        //draw circle
        cvCircle( roi, cvPoint( radius, radius), radius, cvScalarAll( 255 ), -1, 8, 0 );

        //extract subimage
        cvAnd( img, img, res, roi );

        circlesROI[i] = cvCloneImage( res );

        cvNamedWindow("res", 1);
        cvShowImage("res", res);
        cvWaitKey( 0 );

    }

    cvDestroyAllWindows();
    cvReleaseImage( &img );

    return circlesROI;
}

0 个答案:

没有答案