Project import generated by Copybara.

GitOrigin-RevId: 4143ead7dd769b489c313bb9e8856002736f5ecd
This commit is contained in:
MediaPipe Team 2020-06-08 09:33:26 -07:00 committed by jqtang
parent cd2b69d58c
commit b09cc090d4
5 changed files with 31 additions and 5 deletions

View File

@ -91,8 +91,8 @@ each project.
[the label map](https://github.com/google/mediapipe/blob/master/mediapipe/models/face_detection_front_labelmap.txt).
```bash
bazel build -c opt mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectiongpu:binary_graph
cp bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectiongpu/facedetectiongpu.binarypb /path/to/your/app/src/main/assets/
bazel build -c opt mediapipe/mediapipe/graphs/face_detection:mobile_gpu_binary_graph
cp bazel-bin/mediapipe/graphs/face_detection/mobile_gpu.binarypb /path/to/your/app/src/main/assets/
cp mediapipe/models/face_detection_front.tflite /path/to/your/app/src/main/assets/
cp mediapipe/models/face_detection_front_labelmap.txt /path/to/your/app/src/main/assets/
```
@ -130,7 +130,7 @@ each project.
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.google.guava:guava:27.0.1-android'
implementation 'com.google.guava:guava:27.0.1-android'
implementation 'com.google.protobuf:protobuf-java:3.11.4''
implementation 'com.google.protobuf:protobuf-java:3.11.4'
// CameraX core library
def camerax_version = "1.0.0-alpha06"
implementation "androidx.camera:camera-core:$camerax_version"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -48,6 +48,7 @@ constexpr char kNormReferenceRectTag[] = "NORM_REFERENCE_RECT";
class RectProjectionCalculator : public CalculatorBase {
public:
static ::mediapipe::Status GetContract(CalculatorContract* cc);
::mediapipe::Status Open(CalculatorContext* cc) override;
::mediapipe::Status Process(CalculatorContext* cc) override;
};
REGISTER_CALCULATOR(RectProjectionCalculator);
@ -60,6 +61,12 @@ REGISTER_CALCULATOR(RectProjectionCalculator);
return ::mediapipe::OkStatus();
}
::mediapipe::Status RectProjectionCalculator::Open(CalculatorContext* cc) {
cc->SetOffset(TimestampDiff(0));
return ::mediapipe::OkStatus();
}
::mediapipe::Status RectProjectionCalculator::Process(CalculatorContext* cc) {
if (cc->Inputs().Tag(kNormRectTag).IsEmpty()) {
return ::mediapipe::OkStatus();

View File

@ -83,6 +83,7 @@ class GlScalerCalculator : public CalculatorBase {
GlCalculatorHelper helper_;
int dst_width_ = 0;
int dst_height_ = 0;
float dst_scale_ = -1.f;
FrameRotation rotation_;
std::unique_ptr<QuadRenderer> rgb_renderer_;
std::unique_ptr<QuadRenderer> yuv_renderer_;
@ -142,6 +143,9 @@ REGISTER_CALCULATOR(GlScalerCalculator);
if (options.has_output_height()) {
dst_height_ = options.output_height();
}
if (options.has_output_scale()) {
dst_scale_ = options.output_scale();
}
if (options.has_rotation()) {
rotation_ccw = options.rotation();
}
@ -283,8 +287,18 @@ void GlScalerCalculator::GetOutputDimensions(int src_width, int src_height,
if (dst_width_ > 0 && dst_height_ > 0) {
*dst_width = dst_width_;
*dst_height = dst_height_;
} else if (rotation_ == FrameRotation::k90 ||
rotation_ == FrameRotation::k270) {
return;
}
if (dst_scale_ > 0) {
// Scales the destination size, but just uses src size as a temporary for
// calculations.
src_width = static_cast<int>(src_width * dst_scale_);
src_height = static_cast<int>(src_height * dst_scale_);
// Round to nearest multiply of 4 for better memory alignment.
src_width = ((src_width + 2) >> 2) << 2;
src_height = ((src_height + 2) >> 2) << 2;
}
if (rotation_ == FrameRotation::k90 || rotation_ == FrameRotation::k270) {
*dst_width = src_height;
*dst_height = src_width;
} else {

View File

@ -19,6 +19,7 @@ package mediapipe;
import "mediapipe/framework/calculator.proto";
import "mediapipe/gpu/scale_mode.proto";
// Next id: 8.
message GlScalerCalculatorOptions {
extend CalculatorOptions {
optional GlScalerCalculatorOptions ext = 166373014;
@ -27,6 +28,10 @@ message GlScalerCalculatorOptions {
// Output dimensions.
optional int32 output_width = 1;
optional int32 output_height = 2;
// A scale factor for output size, while keeping aspect ratio. It has lower
// priority than the above two fields. That is, it is effective only when the
// above two fields are unset.
optional float output_scale = 7 [default = 1.0];
// Counterclockwise rotation in degrees. Must be a multiple of 90.
optional int32 rotation = 3;
// Flip the output texture vertically. This is applied after rotation.