Ask Your Question

Elmira's profile - activity

2017-04-24 11:28:19 -0600 received badge  Popular Question (source)
2016-01-15 10:06:53 -0600 received badge  Nice Question (source)
2015-11-13 07:07:58 -0600 asked a question Invali arguments in ConvexHull Android ndk and Opencv

Hello All, I have this C ++ OpenCV code in my jni folder of android application hello-jni.cpp. I just want to find and draw convexhull but cause of hull[i] the convexhull method generate an error "invalid arguments". If I cast (vector<point>(hull[i])) the program run and generate this error :

libc "Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1)"

It's three weeks I'm working on this but I couldn't find solution.

any help really really appreciate .

     #include <jni.h>
   #include <opencv2/core/core.hpp>
   #include <opencv2/highgui/highgui.hpp>
   #include <opencv2/imgproc/imgproc.hpp>
    #include <android/log.h>
    #include <opencv/cv.h>
      #include <vector>
      #include <cmath>
     #include <opencv2/opencv.hpp>
     #include <string.h>
     #include <stdio.h>
      #include <stdlib.h>


   #define  LOG_TAG    "hellojni"
   #define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
   #define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
   #define ORIGCOL2ANDROIDORGCOL CV_BGR2BGRA

   using namespace std;
   using namespace cv;




 extern "C" {


 JNIEXPORT jint JNICALL  Java_com_elmira_getconvexhull_MainActivity_convertNativeGray(
    JNIEnv*, jobject, jlong addrRgba, jlong addrGray);
  JNIEXPORT jint JNICALL  Java_com_elmira_getconvexhull_MainActivity_convertNativeGray(
    JNIEnv*, jobject, jlong addrRgba, jlong addrGray) {

 Mat& mRgb = *(Mat*) addrRgba;
  Mat& mGray = *(Mat*) addrGray;

int conv=0;
jint retVal;


Mat src; Mat src_gray;
    src = mRgb;

    cvtColor(src, src_gray, CV_BGR2GRAY);
    blur(src_gray, src_gray, Size(3, 3));


    Mat src_copy = src.clone();
    Mat threshold_output;
    vector<vector<Point> > contours;
    vector<vector<Point> > hull( contours.size() );
    vector<Vec4i> hierarchy;
     int thresh = 100;

       threshold( src_gray, threshold_output, thresh, 255,  THRESH_BINARY||CV_THRESH_OTSU );

       /// Find contours
       findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );


    __android_log_print(ANDROID_LOG_INFO, "inmethod", "size %d *** %d", contours.size(),threshold_output.cols);

    for (int i =0; i < contours.size(); i++)
    {

        convexHull( Mat(contours[i]),hull[i],false,false);

    }

    __android_log_print(ANDROID_LOG_INFO, "inmethod", "sizehull %d *** %d*** %d", hull.size(),threshold_output.cols,contours.size());
    Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );
    Scalar color = Scalar( 255,0,0 );
    Scalar colorr = Scalar( 0,0,255 );
     for( int i = 0; i< contours.size(); i++ )
          {

          }

    mGray=drawing;
retVal = (jint) conv;

return retVal;

      }
    }
2015-11-12 00:01:22 -0600 received badge  Enthusiast
2015-11-09 13:00:26 -0600 commented question Android OpenCV Error: Assertion failed

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.

2015-11-08 13:36:56 -0600 asked a question Android OpenCV Error: Assertion failed

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.

2015-11-02 08:49:25 -0600 received badge  Student (source)
2015-10-02 00:41:02 -0600 asked a question opencv manager wasn't initialized correctly on galaxy s6!

Hello All, I developed an image processing app,when I installed it on my galaxy s6 it wants Opencv Manager I download it from Google play but when I open the app this error appear and app close :"opencv manager was not initialized correctly.Application will be shutdown. "

what's the problem? any help really appreciate. regards.