I have a problem in my native code because in my c ++ code I can not save the images I receive from the JAVA part.
我的本机代码有问题,因为在我的c ++代码中,我无法保存从JAVA部分收到的图像。
I tried using cv::imwrite
but the image is never saved in the path and in the corresponding folder.
我尝试使用cv :: imwrite,但图像永远不会保存在路径和相应的文件夹中。
My JNI code is as follows:
我的JNI代码如下:
extern "C"{
JNIEXPORT jintArray JNICALL Java_com_example_testNativeCode_DisplayImage_FindFeatures(JNIEnv* env, jclass obj, jintArray bufImg, jint w, jint h){
jint *cbuf;
cbuf = env->GetIntArrayElements(bufImg, 0);
if(cbuf==NULL){
return 0;
}
cv::Mat mImg(h,w,CV_8UC4, (unsigned char*)cbuf);
cv::imwrite("../SaveImage/img.png", mImg);
}
}
I use android studio 2.3.3 and OpenCv 3.1.0. I put in the manifest:
我使用android studio 2.3.3和OpenCv 3.1.0。我把清单放进去了:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I want to know if it was possible to record an image with cv::imwrite
? How else can I do to save it?
我想知道是否可以使用cv :: imwrite录制图像?我怎么办才能保存它?
1 个解决方案
#1
0
I am experiencing the same problem,but i solve it by this steps:
我遇到了同样的问题,但我通过以下步骤解决了这个问题:
1.request permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
2.Manually open the permission switch
2.手动打开权限开关
3.Close app and clear task
3.关闭应用程序并清除任务
4.Open your project app and try again,it it working to me.
4.打开您的项目应用程序,然后重试,它对我有用。
If it is not working for you,uninstall and reinstall app,and repeat the above steps
如果它不适合您,请卸载并重新安装应用程序,然后重复上述步骤
#1
0
I am experiencing the same problem,but i solve it by this steps:
我遇到了同样的问题,但我通过以下步骤解决了这个问题:
1.request permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
2.Manually open the permission switch
2.手动打开权限开关
3.Close app and clear task
3.关闭应用程序并清除任务
4.Open your project app and try again,it it working to me.
4.打开您的项目应用程序,然后重试,它对我有用。
If it is not working for you,uninstall and reinstall app,and repeat the above steps
如果它不适合您,请卸载并重新安装应用程序,然后重复上述步骤