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(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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#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> contours;
vector> hull( contours.size() );
vector 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;
}
}
↧