Move loading tasks-vision-jni to individual vision task class

PiperOrigin-RevId: 564840343
This commit is contained in:
MediaPipe Team 2023-09-12 14:50:36 -07:00 committed by Copybara-Service
parent 4ba1dadf92
commit dbcdb44f7c
13 changed files with 39 additions and 1 deletions

View File

@ -34,7 +34,6 @@ public class BaseVisionTaskApi implements AutoCloseable {
protected final String normRectStreamName;
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
ProtoUtil.registerTypeName(NormalizedRect.class, "mediapipe.NormalizedRect");
}

View File

@ -81,6 +81,10 @@ public final class FaceDetector extends BaseVisionTaskApi {
private static final String TASK_GRAPH_NAME =
"mediapipe.tasks.vision.face_detector.FaceDetectorGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates a {@link FaceDetector} instance from a model file and the default {@link
* FaceDetectorOptions}.

View File

@ -86,6 +86,10 @@ public final class FaceLandmarker extends BaseVisionTaskApi {
private static final String TASK_GRAPH_NAME =
"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates a {@link FaceLandmarker} instance from a model asset bundle path and the default {@link
* FaceLandmarkerOptions}.

View File

@ -88,6 +88,10 @@ public final class FaceStylizer extends BaseVisionTaskApi {
"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph";
private final boolean hasResultListener;
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates an {@link FaceStylizer} instance from an {@link FaceStylizerOptions}.
*

View File

@ -93,6 +93,10 @@ public final class GestureRecognizer extends BaseVisionTaskApi {
private static final String TASK_GRAPH_NAME =
"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates a {@link GestureRecognizer} instance from a model file and the default {@link
* GestureRecognizerOptions}.

View File

@ -89,6 +89,10 @@ public final class HandLandmarker extends BaseVisionTaskApi {
private static final String TASK_GRAPH_NAME =
"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates a {@link HandLandmarker} instance from a model file and the default {@link
* HandLandmarkerOptions}.

View File

@ -104,6 +104,7 @@ public final class ImageClassifier extends BaseVisionTaskApi {
"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
ProtoUtil.registerTypeName(
ClassificationsProto.ClassificationResult.class,
"mediapipe.tasks.components.containers.proto.ClassificationResult");

View File

@ -87,6 +87,7 @@ public final class ImageEmbedder extends BaseVisionTaskApi {
"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
ProtoUtil.registerTypeName(
EmbeddingsProto.EmbeddingResult.class,
"mediapipe.tasks.components.containers.proto.EmbeddingResult");

View File

@ -80,6 +80,10 @@ public final class ImageGenerator extends BaseVisionTaskApi {
private CachedInputs cachedInputs = new CachedInputs();
private boolean inProcessing = false;
static {
System.loadLibrary("mediapipe_tasks_vision_image_generator_jni");
}
/**
* Creates an {@link ImageGenerator} instance from an {@link ImageGeneratorOptions}.
*

View File

@ -93,6 +93,10 @@ public final class ImageSegmenter extends BaseVisionTaskApi {
private boolean hasResultListener = false;
private List<String> labels = new ArrayList<>();
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates an {@link ImageSegmenter} instance from an {@link ImageSegmenterOptions}.
*

View File

@ -102,6 +102,7 @@ public final class InteractiveSegmenter extends BaseVisionTaskApi {
private List<String> labels = new ArrayList<>();
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
ProtoUtil.registerTypeName(RenderData.class, "mediapipe.RenderData");
}

View File

@ -113,6 +113,10 @@ public final class ObjectDetector extends BaseVisionTaskApi {
private static final int IMAGE_OUT_STREAM_INDEX = 1;
private static final String TASK_GRAPH_NAME = "mediapipe.tasks.vision.ObjectDetectorGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates an {@link ObjectDetector} instance from a model file and the default {@link
* ObjectDetectorOptions}.

View File

@ -86,6 +86,10 @@ public final class PoseLandmarker extends BaseVisionTaskApi {
private static final String TASK_GRAPH_NAME =
"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph";
static {
System.loadLibrary("mediapipe_tasks_vision_jni");
}
/**
* Creates a {@link PoseLandmarker} instance from a model file and the default {@link
* PoseLandmarkerOptions}.