Move loading tasks-vision-jni to individual vision task class
PiperOrigin-RevId: 564840343
This commit is contained in:
parent
4ba1dadf92
commit
dbcdb44f7c
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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}.
|
||||
|
|
|
@ -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}.
|
||||
|
|
|
@ -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}.
|
||||
*
|
||||
|
|
|
@ -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}.
|
||||
|
|
|
@ -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}.
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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}.
|
||||
*
|
||||
|
|
|
@ -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}.
|
||||
*
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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}.
|
||||
|
|
|
@ -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}.
|
||||
|
|
Loading…
Reference in New Issue
Block a user