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*)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)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)hg->hullP[hg- >cIdx]), false, true);
convexHull(Mat(hg->contours[hg->cIdx]),((vector) hg->hullI[hg->cIdx]), false, false);
if (((vector)hg->contours[hg->cIdx]).size()>3){
convexityDefects(((vector)hg->contours[hg->cIdx]), ((vector)hg->hullI[hg->cIdx]),((vector) 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.
↧