Note that there are some explanatory texts on larger screens.

plurals
  1. POJNI, C++ problems
    primarykey
    data
    text
    <p>I did an Opencv's application en windows and now I am using JNI to convert this code to Android but I am having some problems. In concrete my native code not do nothing.</p> <p>This is my Java class where I define my native methods:</p> <pre><code>package com.example.telo3; import org.opencv.core.Mat; public class Process { static { System.loadLibrary("nativo"); } public Process(){ dir=inicializar_nativo(); } public void Procesar(Mat framedetect, Mat framedraw){ procesar_nativo(dir,framedetect.getNativeObjAddr(),framedraw.getNativeObjAddr()); } private long dir; private static native long inicializar_nativo(); private static native void procesar_nativo(long thiz, long framedetect, long framedraw); </code></pre> <p>}</p> <p>This is my JNI code:</p> <pre><code>#include "nativo.h" #include &lt;opencv2/objdetect/objdetect.hpp&gt; #include &lt;opencv2/highgui/highgui.hpp&gt; #include &lt;opencv2/imgproc/imgproc.hpp&gt; #include "opencv2/video/tracking.hpp" #include &lt;iostream&gt; #include &lt;stdio.h&gt; #include "FaceDetector.h" #include "Draw.h" #include "Almacena.h" #include "Runnable.h" using namespace std; using namespace cv; #include &lt;android/log.h&gt; #define LOG_TAG "NATIVO" #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) struct variables { Almacena almacena; Draw draw; FaceDetector face_detector; }; JNIEXPORT jlong JNICALL Java_com_example_telo3_Process_inicializar_1nativo( JNIEnv *, jobject) { long dir = (long) new variables(); return (dir); } JNIEXPORT void JNICALL Java_com_example_telo3_Process_procesar_1nativo(JNIEnv *, jobject, jlong dir, jlong framedetect, jlong framedraw) { Mat* telo =(Mat*)framedetect; Mat* telo2= (Mat*)framedraw; ((variables*)dir)-&gt;almacena = ((variables*)dir)-&gt;face_detector.Detect(*telo); //almacena = face_detector.Detect(frame_gray); ((variables*)dir)-&gt;draw.Dibujar(*telo2,((variables*)dir)-&gt;almacena); //frame_capturado = draw.Dibujar(frame_capturado, almacena); if( (((variables*)dir)-&gt;almacena.get_faces()).size() ==0){ LOGD("no detecto caras"); } } </code></pre> <p>I think that I use the Jni correctly but the function Detect not works correctly because when I uses this if return 0.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload