Android OpenCV Error: Assertion failed

asked 2015-11-08 13:36:56 -0500

Elmira gravatar image

I'm developing an android image processing application using Opencv. in this App I take each frame of camera and process it to find hand. I searched a lot and did some things but I couldn't solve the problem:

1- I resized the input image to reduce the size cause I'm working on mobile.

2- I made a small application with an small image as input and exactly use this method to find convex hull but again this error occurred .

the error is :

    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

exactly in below line of the makeContours() method:

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

And the makeContours() mehtod where I make convexhull and convexdefects is this:

  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);
       }
      }
     }

Any help really appreciate.

edit retag flag offensive close merge delete

Comments

Android is Java.... so there are no ->, nor vector (except if you have defined it; use List instead)...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-09 07:41:40 -0500 )edit
1

thanks for your response.I'm using ndk and developing in c++ .this method is in .cpp file and in jni folder of my application,It's not in java code.

Elmira gravatar imageElmira ( 2015-11-09 13:00:26 -0500 )edit