CLAHE in android

asked 2015-01-08 02:51:59 -0600

joyrae gravatar image

updated 2015-01-08 02:54:53 -0600

I used JNI for clahe by the column, http://answers.opencv.org/question/27....

But there is error in clahe->apply(Mat m1, Mat m2) .

I couldn't find the reason because of none of the error message. (Just turn down the application.)

So Plz help me...T.T

The Code in JNI

JNIEXPORT int JNICALL Java_com_example_i3bolometerapp_MainActivity_InitCLAHE( JNIEnv *env, jobject thiz, jintArray disp, jint _width, jint _height, jlong addrClahe, jlong addrClaheDst ) {

Mat &mGr  = *(Mat*)addrClahe;
Mat &mGr2  = *(Mat*)addrClaheDst;

Ptr<CLAHE> clahe = createCLAHE();
clahe->setClipLimit(5);
clahe->apply(mGr, mGr2);

return mGr.cols;

}

Actually, the column of mGr is returned well. So i dont think mat data is wrong.

edit retag flag offensive close merge delete

Comments

could you add your java code, too ? did you pass in a new Mat() for dst ?

berak gravatar imageberak ( 2015-01-08 03:52:37 -0600 )edit

At Start,

     if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mOpenCVCallBack))
     {
         Log.e("TEST", "Cannot connect to OpenCV Manager");
     }

CallBack Function,

private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
        case LoaderCallbackInterface.SUCCESS: {
            Log.i("TEST", "OpenCV loaded successfully");

            System.loadLibrary("clahe");

            m_matClahe = new Mat(commData.getWindowingHeight(), commData.getWindowingWidth(), CvType.CV_8UC1);
            m_matClaheDst = new Mat(commData.getWindowingHeight(), commData.getWindowingWidth(), CvType.CV_8UC1);               

            // tmp = new Mat(commData.getWindowingHeight(),
            // commData.getWindowingWidth(), CvType.CV_8UC1);
joyrae gravatar imagejoyrae ( 2015-01-09 22:41:51 -0600 )edit

Use CLAHE,

                    Utils.bitmapToMat(commData.m_bitMain, m_matClahe);

                    int temp = InitCLAHE( commData.m_piDispData, commData.getWindowingWidth(), commData.getWindowingHeight(), m_matClahe.getNativeObjAddr(), m_matClaheDst.getNativeObjAddr());
                    Utils.matToBitmap(m_matClaheDst, commData.m_bitMain);
                    m_textLog.setText(String.format("Return : %d, %d", m_matClaheDst.getNativeObjAddr(), temp));
joyrae gravatar imagejoyrae ( 2015-01-09 22:42:32 -0600 )edit

CLAHE is used in handler,

joyrae gravatar imagejoyrae ( 2015-01-09 22:43:03 -0600 )edit

Dst is initailized in callback function. So i think this is not problem,

And i checked the address of dst.

joyrae gravatar imagejoyrae ( 2015-01-09 22:43:54 -0600 )edit