Skip to content

Commit

Permalink
Added fictitious delete methods, changes for android build (#11)
Browse files Browse the repository at this point in the history
* Added fictitious delete methods, changes for android build

* fixed comments
  • Loading branch information
likholat authored Nov 30, 2020
1 parent bb6ee24 commit 5f7dd23
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 10 deletions.
4 changes: 3 additions & 1 deletion modules/java_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ include(UseJava)

set(JAVA_AWT_INCLUDE_PATH NotNeeded)

find_package(JNI REQUIRED)
if (NOT CMAKE_CROSSCOMPILING)
find_package(JNI REQUIRED)
endif()

# Build native part

Expand Down
8 changes: 1 addition & 7 deletions modules/java_api/cpp/cnn_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ JNIEXPORT jobject JNICALL Java_org_intel_openvino_CNNNetwork_GetInputsInfo(JNIEn
{
CNNNetwork *network = (CNNNetwork *)addr;
const InputsDataMap &inputs_map = network->getInputsInfo();

jclass hashMapClass = env->FindClass("java/util/HashMap");
jmethodID hashMapInit = env->GetMethodID(hashMapClass, "<init>", "()V");
jobject hashMapObj = env->NewObject(hashMapClass, hashMapInit);
Expand All @@ -65,8 +65,6 @@ JNIEXPORT jobject JNICALL Java_org_intel_openvino_CNNNetwork_GetInputsInfo(JNIEn
env->CallObjectMethod(hashMapObj, hashMapPut, env->NewStringUTF(item.first.c_str()), inputInfoObj);
}

env->PopLocalFrame(hashMapObj);

return hashMapObj;
}
catch (const std::exception &e)
Expand Down Expand Up @@ -102,8 +100,6 @@ JNIEXPORT jobject JNICALL Java_org_intel_openvino_CNNNetwork_GetOutputsInfo(JNIE
env->CallObjectMethod(hashMapObj, hashMapPut, env->NewStringUTF(item.first.c_str()), outputInfoObj);
}

env->PopLocalFrame(hashMapObj);

return hashMapObj;
}
catch (const std::exception &e)
Expand Down Expand Up @@ -160,8 +156,6 @@ JNIEXPORT jobject JNICALL Java_org_intel_openvino_CNNNetwork_getInputShapes(JNIE
env->CallObjectMethod(hashMapObj, hashMapPut, env->NewStringUTF(item.first.c_str()), result);
}

env->PopLocalFrame(hashMapObj);

return hashMapObj;
}
catch (const std::exception &e)
Expand Down
8 changes: 8 additions & 0 deletions modules/java_api/cpp/data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <inference_engine.hpp>

#include "openvino_java.hpp"
#include "jni_common.hpp"

/* We don't use delete operator for native object because we don't own this object:
no new operator has been used to allocate memory for it */
JNIEXPORT void JNICALL Java_org_intel_openvino_Data_delete(JNIEnv *env, jobject obj, jlong addr) {}
1 change: 0 additions & 1 deletion modules/java_api/cpp/infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ JNIEXPORT jobject JNICALL Java_org_intel_openvino_InferRequest_GetPerformanceCou
env->CallObjectMethod(hashMap_object, put_method_id, env->NewStringUTF(itr.first.c_str()), IEProfileInfo);
}

env->PopLocalFrame(hashMap_object);
return hashMap_object;
}
catch (const std::exception &e)
Expand Down
4 changes: 4 additions & 0 deletions modules/java_api/cpp/input_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ JNIEXPORT jlong JNICALL Java_org_intel_openvino_InputInfo_GetTensorDesc(JNIEnv *
}
return 0;
}

/* We don't use delete operator for native object because we don't own this object:
no new operator has been used to allocate memory for it */
JNIEXPORT void JNICALL Java_org_intel_openvino_InputInfo_delete(JNIEnv *env, jobject obj, jlong addr) {}
7 changes: 7 additions & 0 deletions modules/java_api/cpp/openvino_java.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ JNIEXPORT jint JNICALL Java_org_intel_openvino_InputInfo_getLayout(JNIEnv *, job
JNIEXPORT void JNICALL Java_org_intel_openvino_InputInfo_SetPrecision(JNIEnv *, jobject, jlong, jint);
JNIEXPORT jint JNICALL Java_org_intel_openvino_InputInfo_getPrecision(JNIEnv *, jobject, jlong);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_InputInfo_GetTensorDesc(JNIEnv *, jobject, jlong);
JNIEXPORT void JNICALL Java_org_intel_openvino_InputInfo_delete(JNIEnv *, jobject, jlong);

//
// PreProcessInfo
//
JNIEXPORT void JNICALL Java_org_intel_openvino_PreProcessInfo_SetResizeAlgorithm(JNIEnv *, jobject, jlong, jint);
JNIEXPORT void JNICALL Java_org_intel_openvino_PreProcessInfo_delete(JNIEnv *, jobject, jlong);

//
// TensorDesc
Expand All @@ -106,6 +108,11 @@ JNIEXPORT jstring JNICALL Java_org_intel_openvino_Parameter_asString(JNIEnv *, j
JNIEXPORT jint JNICALL Java_org_intel_openvino_Parameter_asInt(JNIEnv *, jobject, jlong);
JNIEXPORT void JNICALL Java_org_intel_openvino_Parameter_delete(JNIEnv *, jobject, jlong);

//
// Data
//
JNIEXPORT void JNICALL Java_org_intel_openvino_Data_delete(JNIEnv *, jobject, jlong);

#ifdef __cplusplus
}
#endif
4 changes: 4 additions & 0 deletions modules/java_api/cpp/pre_process_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ JNIEXPORT void JNICALL Java_org_intel_openvino_PreProcessInfo_SetResizeAlgorithm
throwJavaException(env, 0, method_name);
}
}

/* We don't use delete operator for native object because we don't own this object:
no new operator has been used to allocate memory for it */
JNIEXPORT void JNICALL Java_org_intel_openvino_PreProcessInfo_delete(JNIEnv *env, jobject obj, jlong addr) {}
4 changes: 4 additions & 0 deletions modules/java_api/org/intel/openvino/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ public class Data extends IEWrapper {
protected Data(long addr) {
super(addr);
}

/*----------------------------------- native methods -----------------------------------*/
@Override
protected native void delete(long nativeObj);
}
3 changes: 3 additions & 0 deletions modules/java_api/org/intel/openvino/InputInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ public TensorDesc getTensorDesc() {
private static native int getPrecision(long addr);

private native long GetTensorDesc(long addr);

@Override
protected native void delete(long nativeObj);
}
3 changes: 3 additions & 0 deletions modules/java_api/org/intel/openvino/PreProcessInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ public void setResizeAlgorithm(ResizeAlgorithm resizeAlgorithm) {

/*----------------------------------- native methods -----------------------------------*/
private static native void SetResizeAlgorithm(long addr, int resizeAlgorithm);

@Override
protected native void delete(long nativeObj);
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ public void run() {
// Drawing only objects with >70% probability
if (confidence < CONFIDENCE_THRESHOLD) continue;

int label = (int) (detection[curProposal * 7 + 1]);
int xmin = (int) (detection[curProposal * 7 + 3] * img.cols());
int ymin = (int) (detection[curProposal * 7 + 4] * img.rows());
int xmax = (int) (detection[curProposal * 7 + 5] * img.cols());
Expand Down

0 comments on commit 5f7dd23

Please sign in to comment.