Project import generated by Copybara.

GitOrigin-RevId: 6e5aa035cd1f6a9333962df5d3ab97a05bd5744e
This commit is contained in:
MediaPipe Team
2022-06-28 12:11:05 +00:00
committed by Sebastian Schmidt
parent 4a20e9909d
commit c688862570
144 changed files with 5772 additions and 2118 deletions
@@ -15,10 +15,10 @@
package com.google.mediapipe.examples.facedetection;
import android.opengl.GLES20;
import com.google.mediapipe.formats.proto.DetectionProto.Detection;
import com.google.mediapipe.solutioncore.ResultGlRenderer;
import com.google.mediapipe.solutions.facedetection.FaceDetectionResult;
import com.google.mediapipe.solutions.facedetection.FaceKeypoint;
import com.google.mediapipe.formats.proto.DetectionProto.Detection;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
@@ -23,9 +23,9 @@ import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import androidx.appcompat.widget.AppCompatImageView;
import com.google.mediapipe.formats.proto.DetectionProto.Detection;
import com.google.mediapipe.solutions.facedetection.FaceDetectionResult;
import com.google.mediapipe.solutions.facedetection.FaceKeypoint;
import com.google.mediapipe.formats.proto.DetectionProto.Detection;
/** An ImageView implementation for displaying {@link FaceDetectionResult}. */
public class FaceDetectionResultImageView extends AppCompatImageView {
@@ -279,35 +279,45 @@ mediapipe::autoflip::RectF ShiftDetection(
}
absl::Status UpdateRanges(const SalientRegion& region,
const float shift_vertical,
const float shift_horizontal, float* xmin,
float* xmax, float* ymin, float* ymax) {
const float shift_horizontal,
const float pad_vertical, const float pad_horizontal,
float* xmin, float* xmax, float* ymin, float* ymax) {
if (!region.has_location_normalized()) {
return mediapipe::UnknownErrorBuilder(MEDIAPIPE_LOC)
<< "SalientRegion did not have location normalized set.";
}
auto location = ShiftDetection(region.location_normalized(), shift_vertical,
shift_horizontal);
*xmin = fmin(*xmin, location.x());
*xmax = fmax(*xmax, location.x() + location.width());
*ymin = fmin(*ymin, location.y());
*ymax = fmax(*ymax, location.y() + location.height());
const float x_padding = pad_horizontal * location.width();
const float y_padding = pad_vertical * location.height();
*xmin = fmin(*xmin, location.x() - x_padding);
*xmax = fmax(*xmax, location.x() + location.width() + x_padding);
*ymin = fmin(*ymin, location.y() - y_padding);
*ymax = fmax(*ymax, location.y() + location.height() + y_padding);
return absl::OkStatus();
}
absl::Status UpdateRanges(const mediapipe::Detection& detection,
const float shift_vertical,
const float shift_horizontal, float* xmin,
float* xmax, float* ymin, float* ymax) {
const float shift_horizontal,
const float pad_vertical, const float pad_horizontal,
float* xmin, float* xmax, float* ymin, float* ymax) {
RET_CHECK(detection.location_data().format() ==
mediapipe::LocationData::RELATIVE_BOUNDING_BOX)
<< "Face detection input is lacking required relative_bounding_box()";
const auto& location =
ShiftDetection(detection.location_data().relative_bounding_box(),
shift_vertical, shift_horizontal);
*xmin = fmin(*xmin, location.xmin());
*xmax = fmax(*xmax, location.xmin() + location.width());
*ymin = fmin(*ymin, location.ymin());
*ymax = fmax(*ymax, location.ymin() + location.height());
const float x_padding = pad_horizontal * location.width();
const float y_padding = pad_vertical * location.height();
*xmin = fmin(*xmin, location.xmin() - x_padding);
*xmax = fmax(*xmax, location.xmin() + location.width() + x_padding);
*ymin = fmin(*ymin, location.ymin() - y_padding);
*ymax = fmax(*ymax, location.ymin() + location.height() + y_padding);
return absl::OkStatus();
}
@@ -818,7 +828,9 @@ absl::Status ContentZoomingCalculator::GetDetectionsBox(
*only_required_found = true;
MP_RETURN_IF_ERROR(UpdateRanges(
region, options_.detection_shift_vertical(),
options_.detection_shift_horizontal(), xmin, xmax, ymin, ymax));
options_.detection_shift_horizontal(),
options_.extra_vertical_padding(),
options_.extra_horizontal_padding(), xmin, xmax, ymin, ymax));
}
}
@@ -864,7 +876,9 @@ absl::Status ContentZoomingCalculator::GetDetectionsBox(
*only_required_found = true;
MP_RETURN_IF_ERROR(UpdateRanges(
detection, options_.detection_shift_vertical(),
options_.detection_shift_horizontal(), xmin, xmax, ymin, ymax));
options_.detection_shift_horizontal(),
options_.extra_vertical_padding(),
options_.extra_horizontal_padding(), xmin, xmax, ymin, ymax));
}
}
}
@@ -19,7 +19,7 @@ package mediapipe.autoflip;
import "mediapipe/examples/desktop/autoflip/quality/kinematic_path_solver.proto";
import "mediapipe/framework/calculator.proto";
// NextTag: 19
// NextTag: 21
message ContentZoomingCalculatorOptions {
extend mediapipe.CalculatorOptions {
optional ContentZoomingCalculatorOptions ext = 313091992;
@@ -45,12 +45,17 @@ message ContentZoomingCalculatorOptions {
optional int64 height = 2;
}
optional Size target_size = 8;
// Amount to shift an input detection as a ratio of the size (positive:
// Amount to shift an input detection, as a ratio of its size (positive:
// down/right, negative: up/left). Use a negative value to increase padding
// above/left of an object, positive to increase padding below/right of an
// object.
// object. (Applies to one side only)
optional float detection_shift_vertical = 11 [default = 0.0];
optional float detection_shift_horizontal = 12 [default = 0.0];
// Amount to pad around an input detection, as a ratio of its size.
// (Applies to both sides)
optional float extra_vertical_padding = 19 [default = 0.0];
optional float extra_horizontal_padding = 20 [default = 0.0];
// Defines the smallest value in degrees the camera is permitted to zoom.
optional float max_zoom_value_deg = 13 [default = 35];
+3 -1
View File
@@ -35,7 +35,9 @@ objc_library(
"CoreMedia",
"UIKit",
],
visibility = ["//mediapipe:__subpackages__"],
visibility = [
"//mediapipe:__subpackages__",
],
deps = [
"//mediapipe/objc:mediapipe_framework_ios",
"//mediapipe/objc:mediapipe_input_sources_ios",