Android OpenCV错误:断言失败

时间:2015-11-07 20:06:00

标签: android c++ opencv

我正在使用Opencv开发一个Android图像处理应用程序。 在这个应用程序中,我采取每帧相机并处理它找到手。 我经常搜索并做了一些事情,但我无法解决问题:

1-我调整了输入图像的大小以减小尺寸,因为我正在使用手机。

2-我用一个小图像作为输入做了一个小应用程序,并且正好使用这个方法来查找凸包,但是又发生了这个错误。

错误是:

 OpenCV Error: Assertion failed (!fixedSize() || len == ((vector<uchar>*)v)-  >size() / esz) in virtual void cv::_OutputArray::create(int, int const*, int,    int, bool, int) const, file /home/reports/ci/slave_desktop/50-  SDK/opencv/modules/core/src/matrix.cpp, line 1489

正好在makeContours()方法的下面一行:

convexHull(Mat(hg->contours[hg->cIdx]),( (vector<Point>)hg->hullP[hg-  >cIdx]), false, true);    

makeContours()mehtod我在哪里制作凸包和凸面缺陷是这样的:

void makeContours(MyImage *m, HandGesture* hg){
    Mat aBw;

    pyrUp(m->bw, m->bw);
    m->bw.copyTo(aBw);
    findContours(aBw, hg->contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

    hg->initVectors();
    hg->cIdx = findBiggestContour(hg->contours);

      if (hg->cIdx != -1){




    hg->bRect = boundingRect(Mat(hg->contours[hg->cIdx]));

    convexHull(Mat(hg->contours[hg->cIdx]),( (vector<Point>)hg->hullP[hg-  >cIdx]), false, true);

    convexHull(Mat(hg->contours[hg->cIdx]),((vector<int>) hg->hullI[hg->cIdx]), false, false);

    if (((vector<Point>)hg->contours[hg->cIdx]).size()>3){
        convexityDefects(((vector<Point>)hg->contours[hg->cIdx]), ((vector<int>)hg->hullI[hg->cIdx]),((vector<Vec4i>) hg->defects[hg->cIdx]));

        hg->eleminateDefects(m);
    }
    bool isHand = hg->detectIfHand();
    hg->printGestureInfo(m->src);
    if (isHand){
        hg->getFingerTips(m);
        hg->drawFingerTips(m);
        myDrawContours(m, hg);
    }
}
}

任何帮助都非常感激。

0 个答案:

没有答案