opencv在iphone中获取subimage

时间:2011-03-29 16:10:40

标签: iphone opencv

我想在iphone中使用Opencv获取子图像。这段代码中的问题是什么? 来自控制台的错误是:OpenCV错误:cvGetMat中的错误标志(参数或结构字段)(无法识别或不支持的数组类型),文件/Users/macmade/Desktop/OpenCV-iPhone/OpenCV/build/iPhoneSimulator/../../ ./tmp/OpenCV-2.0.0/src/cxcore/cxarray.cpp,第2470行 抛出'cv :: Exception'的实例后终止调用

std::vector<IplImage*> vec_images;
int h = bw->height;
for (int i=0; i<Xleft.size(); ++i) {

    CvRect rect = cvRect(Xleft[i], 0, avgx, h);
    /* dst image */
    IplImage* subimg;
    /* copy ROI to subimg */
    cvSetImageROI(bw, rect);
    cvCopy(bw, subimg, NULL);
    vec_images.push_back(subimg);
    cvResetImageROI(bw);
}
for (int i=0; vec_images.size(); ++i) {
    cvReleaseImage(&vec_images[i]);
}

1 个答案:

答案 0 :(得分:1)

您必须在致电subimg之前初始化cvCopy