Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert rgba to hsv in android (JNI) fjsjfjajfjaskfak

Hello,

i'm trying to learn OpenCV with JNI.

I made a program which tracks an object in Java for android, but now I like to make the same code in C++.

Firstly I would like to convert RGBA to HSV and show this on my screen, but when I run my application I get this error.

Sorry!
The Application Trcker (process com.slani.tracker) has stopped unexpectedly. Please try again.
Force Close

Here is my onCameraFrame method.

@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

    Mat rgba = inputFrame.rgba();
    Mat hsv = new Mat()

    findObject(rgba.getNativeObjAddr(), hsv.getNativeObjAddr());
    return hsv;
}

Here is my JNI

#include <jni.h>
#include <opencv2/highgui/highgui.hpp">
#include <opencv/cv.h">


extern ā€œCā€ {
    JNIEXPORT void JNICALL Java_com_slani_tracker_OpenCamera_findObject(JNIEnv * jenv, jclass, jlong addRgba, jlong addHsv)
    {

        Mat& rgba = *(Mat*)addRgba;
        Mat& hsv = *(Mat*)addHsv;

        cvtColor(rgba, hsv,CV_RGBA2HSV);

}
}

Here is my log file http://bpaste.net/show/21RTfuqxs8wtIMaH2jNL/

Can someone please tell me what I'm doing wrong?

Thanks

Convert rgba to hsv in android (JNI) fjsjfjajfjaskfak(JNI)

Hello,

i'm trying to learn OpenCV with JNI.

I made a program which tracks an object in Java for android, but now I like to make the same code in C++.

Firstly I would like to convert RGBA to HSV and show this on my screen, but when I run my application I get this error.

Sorry!
The Application Trcker (process com.slani.tracker) has stopped unexpectedly. Please try again.
Force Close

Here is my onCameraFrame method.

@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

    Mat rgba = inputFrame.rgba();
    Mat hsv = new Mat()

    findObject(rgba.getNativeObjAddr(), hsv.getNativeObjAddr());
    return hsv;
}

Here is my JNI

#include <jni.h>
#include <opencv2/highgui/highgui.hpp">
#include <opencv/cv.h">


extern ā€œCā€ {
    JNIEXPORT void JNICALL Java_com_slani_tracker_OpenCamera_findObject(JNIEnv * jenv, jclass, jlong addRgba, jlong addHsv)
    {

        Mat& rgba = *(Mat*)addRgba;
        Mat& hsv = *(Mat*)addHsv;

        cvtColor(rgba, hsv,CV_RGBA2HSV);

}
}

Here is my log file http://bpaste.net/show/21RTfuqxs8wtIMaH2jNL/

Can someone please tell me what I'm doing wrong?

Thanks