Skip to content

Commit

Permalink
[JAVA] add Core constructor (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
likholat authored Sep 7, 2022
1 parent a35088e commit fd2ac36
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions modules/java_api/cpp/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore(JNIEnv *env, jobjec
return 0;
}

JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore1(JNIEnv *env, jobject obj, jstring xmlConfigFile)
{

JNI_METHOD("GetCore1",
std::string n_xml = jstringToString(env, xmlConfigFile);
Core *core = new Core(n_xml);
return (jlong)core;
)
return 0;
}

JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_ReadModel(JNIEnv *env, jobject obj, jlong coreAddr, jstring xml)
{
JNI_METHOD("ReadModel",
Expand Down
1 change: 1 addition & 0 deletions modules/java_api/cpp/openvino_java.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ extern "C"

// ov::Core
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore(JNIEnv *, jobject);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_GetCore1(JNIEnv *, jobject, jstring);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_ReadModel(JNIEnv *, jobject, jlong, jstring);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_ReadModel1(JNIEnv *, jobject, jlong, jstring, jstring);
JNIEXPORT jlong JNICALL Java_org_intel_openvino_Core_CompileModel(JNIEnv *, jobject, jlong, jlong, jstring);
Expand Down
11 changes: 9 additions & 2 deletions modules/java_api/org/intel/openvino/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public Core() {
super(GetCore());
}

public Core(String xmlConfigFile) {
super(GetCore1(xmlConfigFile));
}

private static String getLibraryName(String name, String linux_ver) {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
Expand Down Expand Up @@ -114,15 +118,18 @@ public CompiledModel compile_model(Model net, final String device) {
}

/*----------------------------------- native methods -----------------------------------*/

private static native long GetCore();

private static native long GetCore1(String xmlConfigFile);

private static native long ReadModel(long core, final String modelPath);

private static native long ReadModel1(
long core, final String modelPath, final String weightPath);

private static native long CompileModel(long core, long net, final String device);

private static native long GetCore();

@Override
protected native void delete(long nativeObj);
}

0 comments on commit fd2ac36

Please sign in to comment.