MCPcopy Create free account
hub / github.com/cactus-compute/cactus / Java_com_cactus_CactusJNI_nativeImageEmbed

Function Java_com_cactus_CactusJNI_nativeImageEmbed

android/cactus_jni.cpp:451–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449}
450
451JNIEXPORT jfloatArray JNICALL
452Java_com_cactus_CactusJNI_nativeImageEmbed(JNIEnv* env, jobject, jlong handle, jstring imagePath) {
453 if (handle == 0) { throwCactusException(env, "Model not initialized"); return nullptr; }
454
455 const char* path = jstring_to_cstr(env, imagePath);
456 std::vector<float> buffer(4096);
457 size_t embeddingDim = 0;
458
459 int result = cactus_image_embed(
460 reinterpret_cast<cactus_model_t>(handle),
461 path,
462 buffer.data(),
463 buffer.size(),
464 &embeddingDim
465 );
466
467 release_jstring(env, imagePath, path);
468
469 if (result < 0) { throwOnError(env); return nullptr; }
470
471 jfloatArray jarray = env->NewFloatArray(static_cast<jsize>(embeddingDim));
472 if (embeddingDim > 0) {
473 env->SetFloatArrayRegion(jarray, 0, static_cast<jsize>(embeddingDim), buffer.data());
474 }
475 return jarray;
476}
477
478JNIEXPORT jfloatArray JNICALL
479Java_com_cactus_CactusJNI_nativeAudioEmbed(JNIEnv* env, jobject, jlong handle, jstring audioPath) {

Callers

nothing calls this directly

Calls 7

throwCactusExceptionFunction · 0.85
jstring_to_cstrFunction · 0.85
release_jstringFunction · 0.85
throwOnErrorFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.80
cactus_image_embedFunction · 0.50

Tested by

no test coverage detected