Issue
I have an issue with passing a nativeobjectaddres from Java to c++.
This is my java code and findboardimage is a c++ method:
Mat original = new Mat(), processed = new Mat(), res = new Mat();
Utils.bitmapToMat(bitmap[0], original);
if(original.channels()>4){
return null;
}
Logger.d("before native imagetype "+ original.type()+" imagedepth "+original.depth()+" imagechannels "+original.channels());
Logger.d("before address "+original.getNativeObjAddr() );
return findBoardInImage(original.getNativeObjAddr());
c++ method
JNIEXPORT void JNICALL Java_be_appwise_i3snap_1android_helpers_I3ImageProcessor_extractForeground(JNIEnv *env,jlong res) {
cv::Mat *resMat = (cv::Mat *) res;
__android_log_print(ANDROID_LOG_ERROR,"extractforeground ","voor eigen functie col %d rows %d");
*resMat=ImageProcessor::extractForeground(*resMat);
__android_log_print(ANDROID_LOG_ERROR,"extractforeground","na eigen functie col %d rows %d");
}
working: 32 bit armeabi-v7a oneplus x, one plus one, samsung galaxy s4, sony experia m2 and a old samsung tablet
not working: arm64-v8a huawei,samsung s6, nexus 6p
This mat has random number of type and random number of channels which lets me believe the long is 32 bit but gets interpreted 64 bit so the getchannel and gettype function are much bigger than they should be.
Solution
I solved it myself add this in gradle i do notice some performance issues. 64 bit devices are going much slower then 32 bit devices.
ndk {
moduleName "ndksetup"
abiFilters "armeabi-v7a"
}
when you import libraries in gradle and it contains a 64 bit version it will ignore all the 32 bit versions of other libraries thats why my java was 32 bit and my c++ tried to understand it as 64 bit
Also check this link Use Vuforia and io.realm db crash the app
Answered By - dieter115
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.