2 Copyright (c) 2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
18 from .base_representation import BaseRepresentation
21 class PoseEstimationRepresentation(BaseRepresentation):
22 def __init__(self, identifier='', x_values=None, y_values=None, visibility=None, labels=None):
23 super().__init__(identifier)
24 self.x_values = x_values if np.size(x_values) > 0 else []
25 self.y_values = y_values if np.size(y_values) > 0 else []
26 self.visibility = visibility if np.size(visibility) > 0 else [2] * len(x_values)
27 self.labels = labels if labels is not None else np.array([1]*len(x_values))
31 areas = self.metadata.get('areas')
34 x_mins = np.min(self.x_values, axis=1)
35 x_maxs = np.max(self.x_values, axis=1)
36 y_mins = np.min(self.y_values, axis=1)
37 y_maxs = np.max(self.y_values, axis=1)
38 return (x_maxs - x_mins) * (y_maxs - y_mins)
42 rects = self.metadata.get('rects')
45 x_mins = np.min(self.x_values, axis=1)
46 x_maxs = np.max(self.x_values, axis=1)
47 y_mins = np.min(self.y_values, axis=1)
48 y_maxs = np.max(self.y_values, axis=1)
49 return [[x_min, y_min, x_max, y_max] for x_min, y_min, x_max, y_max in zip(x_mins, y_mins, x_maxs, y_maxs)]
53 return len(self.x_values)
56 class PoseEstimationAnnotation(PoseEstimationRepresentation):
60 class PoseEstimationPrediction(PoseEstimationRepresentation):
61 def __init__(self, identifier='', x_values=None, y_values=None, visibility=None, scores=None, labels=None):
62 super().__init__(identifier, x_values, y_values, visibility, labels)
63 self.scores = scores if scores.any() else []