// Copyright 2019 The MediaPipe Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// A protocol buffer containing location information. It allows for storing
// location information related to an image in several formats -- relative
// and absolute bounding boxes, foreground mask.
// See location.h for a helper wrapper to work with the LocationData.
syntax = "proto2";
package mediapipe;
import "mediapipe/framework/formats/annotation/rasterization.proto";
option java_package = "com.google.mediapipe.formats.proto";
option java_outer_classname = "LocationDataProto";
message LocationData {
// The supported formats for representing location data. A single location
// must store its data in exactly one way.
enum Format {
// The full image. This is a handy format when one needs to refer to the
// full image, e.g. one uses global image labels. No other fields need to
// be populated.
GLOBAL = 0;
// A rectangle aka bounding box of an object. The field bounding_box must be
// used to store the location data.
BOUNDING_BOX = 1;
// A rectangle aka bounding box of an object, defined in coordinates
// normalized by the image dimensions. The field relative_bounding_box must
// be used to store the location data.
RELATIVE_BOUNDING_BOX = 2;
// A foreground mask. The field mask must be used to store the location
// data.
MASK = 3;
}
optional Format format = 1;
// A bounding box in pixel units. The box is defined by its upper left corner
// (xmin, ymin) and its width and height.
message BoundingBox {
optional int32 xmin = 1;
optional int32 ymin = 2;
optional int32 width = 3;
optional int32 height = 4;
}
optional BoundingBox bounding_box = 2;
// A bounding box. The box is defined by its upper left corner (xmin, ymin)
// and its width and height, all in coordinates normalized by the image
// dimensions.
message RelativeBoundingBox {
optional float xmin = 1;
optional float ymin = 2;
optional float width = 3;
optional float height = 4;
}
optional RelativeBoundingBox relative_bounding_box = 3;
// A mask of size equivalent to the image size. It encodes a region, which
// can be thought of as a foreground object mask.
message BinaryMask {
// Dimensions of the mask.
optional int32 width = 1;
optional int32 height = 2;
// A rasterization-like format for storing the mask.
optional mediapipe.Rasterization rasterization = 3;
}
optional BinaryMask mask = 4;
// A keypoint. The keypoint is defined by the coordinates (x, y), normalized
// by the image dimensions.
message RelativeKeypoint {
optional float x = 1;
optional float y = 2;
optional string keypoint_label = 3;
optional float score = 4;
}
repeated RelativeKeypoint relative_keypoints = 5;
}