Rename the mediapipe java image container from Image to MPImage.
PiperOrigin-RevId: 482933122
This commit is contained in:
committed by
Copybara-Service
parent
7196db275e
commit
abed54ea30
+4
-3
@@ -30,7 +30,7 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
// ContentResolver dependency
|
||||
import com.google.mediapipe.framework.image.BitmapImageBuilder;
|
||||
import com.google.mediapipe.framework.image.Image;
|
||||
import com.google.mediapipe.framework.image.MPImage;
|
||||
import com.google.mediapipe.tasks.core.BaseOptions;
|
||||
import com.google.mediapipe.tasks.vision.core.RunningMode;
|
||||
import com.google.mediapipe.tasks.vision.objectdetector.ObjectDetectionResult;
|
||||
@@ -98,7 +98,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Log.e(TAG, "Bitmap rotation error:" + e);
|
||||
}
|
||||
if (bitmap != null) {
|
||||
Image image = new BitmapImageBuilder(bitmap).build();
|
||||
MPImage image = new BitmapImageBuilder(bitmap).build();
|
||||
ObjectDetectionResult detectionResult = objectDetector.detect(image);
|
||||
imageView.setData(image, detectionResult);
|
||||
runOnUiThread(() -> imageView.update());
|
||||
@@ -144,7 +144,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
MediaMetadataRetriever.METADATA_KEY_VIDEO_FRAME_COUNT));
|
||||
long frameIntervalMs = duration / numFrames;
|
||||
for (int i = 0; i < numFrames; ++i) {
|
||||
Image image = new BitmapImageBuilder(metaRetriever.getFrameAtIndex(i)).build();
|
||||
MPImage image =
|
||||
new BitmapImageBuilder(metaRetriever.getFrameAtIndex(i)).build();
|
||||
ObjectDetectionResult detectionResult =
|
||||
objectDetector.detectForVideo(image, frameIntervalMs * i);
|
||||
// Currently only annotates the detection result on the first video frame and
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@ import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import com.google.mediapipe.framework.image.BitmapExtractor;
|
||||
import com.google.mediapipe.framework.image.Image;
|
||||
import com.google.mediapipe.framework.image.MPImage;
|
||||
import com.google.mediapipe.tasks.components.containers.Detection;
|
||||
import com.google.mediapipe.tasks.vision.objectdetector.ObjectDetectionResult;
|
||||
|
||||
@@ -40,12 +40,12 @@ public class ObjectDetectionResultImageView extends AppCompatImageView {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an {@link Image} and an {@link ObjectDetectionResult} to render.
|
||||
* Sets a {@link MPImage} and an {@link ObjectDetectionResult} to render.
|
||||
*
|
||||
* @param image an {@link Image} object for annotation.
|
||||
* @param image a {@link MPImage} object for annotation.
|
||||
* @param result an {@link ObjectDetectionResult} object that contains the detection result.
|
||||
*/
|
||||
public void setData(Image image, ObjectDetectionResult result) {
|
||||
public void setData(MPImage image, ObjectDetectionResult result) {
|
||||
if (image == null || result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user