简体   繁体   中英

This code always returns Image not loaded, is the path correct .this is opencv in android NDK

JNIEXPORT jstring JNICALL Java_com_weiss_konrad_arrowapp_NDKInterface_getID(JNIEnv *env, jobject o ){
    Mat img =  imread("storage/emulated/0/DCIM/Camera/IMG_20160506_141333.jpg");
    if(img.empty())                             
    {
        return env->NewStringUTF("Image not loaded");
    }

    return env->NewStringUTF("Image loaded");
}

Different devices may use different paths to store the camera pictures. You must use Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) to find the correct path (sometimes it can even be changed by the end-user). I understand that it is a burden to find call this function from C++, so probably you will find it easier to pass this path from Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM