| 449 | } |
| 450 | |
| 451 | JNIEXPORT jfloatArray JNICALL |
| 452 | Java_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 | |
| 478 | JNIEXPORT jfloatArray JNICALL |
| 479 | Java_com_cactus_CactusJNI_nativeAudioEmbed(JNIEnv* env, jobject, jlong handle, jstring audioPath) { |
nothing calls this directly
no test coverage detected