Problème d'utilisation d'OpenCv sous Android avec JNI
Bonsoir,
J'essaye de développer une petit application Android qui utilise OpenCv pour faire du traitement d'images.
Afin d'avoir un programme réactif, j'utilise du code C++ d'OpenCv grâce à JNI.
Malheureusement, je suis confronté à un problème auquel je ne trouve pas de solution :(
Voici mon code C++ actuel:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
using namespace std;
using namespace cv;
extern "C" {
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial3_Sample3View_FindFeatures(JNIEnv* env, jobject, jint width, jint height, jbyteArray yuv, jintArray bgra)
{
jbyte* _yuv = env->GetByteArrayElements(yuv, 0);
jint* _bgra = env->GetIntArrayElements(bgra, 0);
Mat src(height + height/2, width, CV_8UC1, (unsigned char *)_yuv);
Mat dst(height, width, CV_8UC4, (unsigned char *)_bgra);
Mat temp;
cvtColor(src, temp, CV_YUV420sp2BGR, 4);
cvtColor(temp, dst, CV_BGR2GRAY, 0);
env->ReleaseIntArrayElements(bgra, _bgra, 0);
env->ReleaseByteArrayElements(yuv, _yuv, 0);
}
} |
où yuv représente le "flux" d'entrées et bgra le "flux" de sortie vidéo.
Le problème survient quand j'appelle ceci
Code:
1 2
|
cvtColor(temp, dst, CV_BGR2GRAY, 0); |
où j'obtient: "OpenCV Error: Assertion failed (scn == 3 || scn == 4)..."
Quelqu'un aurait-il une idée ?
Merci d'avance ;)