Project import generated by Copybara.
GitOrigin-RevId: e3a43e4e5e519cd14df7095749059e2613bdcf76
This commit is contained in:
+4
-4
@@ -12,14 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("//mediapipe/gpu:metal.bzl", "metal_library")
|
||||
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
|
||||
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library")
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
# Disabling GPU support is sometimes useful on desktop Linux because SwiftShader can
|
||||
# interfere with desktop GL. b/73494271
|
||||
config_setting(
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace mediapipe {
|
||||
// ROTATION: the counterclockwise rotation angle in degrees. This allows
|
||||
// user to specify different rotation angles for different frames. If this
|
||||
// stream is provided, it will override the ROTATION input side packet.
|
||||
// OUTPUT_DIMENSIONS: the output width and height in pixels.
|
||||
// Additional output streams:
|
||||
// TOP_BOTTOM_PADDING: If use FIT scale mode, this stream outputs the padding
|
||||
// size of the input image in normalized value [0, 1] for top and bottom
|
||||
@@ -103,6 +104,9 @@ REGISTER_CALCULATOR(GlScalerCalculator);
|
||||
if (cc->Inputs().HasTag("ROTATION")) {
|
||||
cc->Inputs().Tag("ROTATION").Set<int>();
|
||||
}
|
||||
if (cc->Inputs().HasTag("OUTPUT_DIMENSIONS")) {
|
||||
cc->Inputs().Tag("OUTPUT_DIMENSIONS").Set<DimensionsPacketType>();
|
||||
}
|
||||
MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc));
|
||||
|
||||
if (cc->InputSidePackets().HasTag("OPTIONS")) {
|
||||
@@ -181,6 +185,18 @@ REGISTER_CALCULATOR(GlScalerCalculator);
|
||||
}
|
||||
|
||||
::mediapipe::Status GlScalerCalculator::Process(CalculatorContext* cc) {
|
||||
if (cc->Inputs().HasTag("OUTPUT_DIMENSIONS")) {
|
||||
if (cc->Inputs().Tag("OUTPUT_DIMENSIONS").IsEmpty()) {
|
||||
// OUTPUT_DIMENSIONS input stream is specified, but value is missing.
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
|
||||
const auto& dimensions =
|
||||
cc->Inputs().Tag("OUTPUT_DIMENSIONS").Get<DimensionsPacketType>();
|
||||
dst_width_ = dimensions[0];
|
||||
dst_height_ = dimensions[1];
|
||||
}
|
||||
|
||||
return helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status {
|
||||
const auto& input = TagOrIndex(cc->Inputs(), "VIDEO", 0).Get<GpuBuffer>();
|
||||
QuadRenderer* renderer = nullptr;
|
||||
@@ -199,7 +215,7 @@ REGISTER_CALCULATOR(GlScalerCalculator);
|
||||
src1 = helper_.CreateSourceTexture(input, 0);
|
||||
src2 = helper_.CreateSourceTexture(input, 1);
|
||||
} else // NOLINT(readability/braces)
|
||||
#endif // __APPLE__
|
||||
#endif // __APPLE__
|
||||
{
|
||||
src1 = helper_.CreateSourceTexture(input);
|
||||
#ifdef __ANDROID__
|
||||
@@ -211,7 +227,7 @@ REGISTER_CALCULATOR(GlScalerCalculator);
|
||||
}
|
||||
renderer = ext_rgb_renderer_.get();
|
||||
} else // NOLINT(readability/braces)
|
||||
#endif // __ANDROID__
|
||||
#endif // __ANDROID__
|
||||
{
|
||||
if (!rgb_renderer_) {
|
||||
rgb_renderer_ = absl::make_unique<QuadRenderer>();
|
||||
|
||||
Reference in New Issue
Block a user