2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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.
19 namespace Tizen.Content.MediaContent
22 /// Represents the face information for media.
26 internal FaceInfo(IntPtr handle)
28 Id = InteropHelper.GetString(handle, Interop.Face.GetId);
29 MediaInfoId = InteropHelper.GetString(handle, Interop.Face.GetMediaId);
31 Tag = InteropHelper.GetString(handle, Interop.Face.GetTag);
32 Orientation = InteropHelper.GetValue<IntPtr, Orientation>(handle, Interop.Face.GetOrientation);
34 Rect = GetRect(handle);
37 private static Rectangle GetRect(IntPtr faceHandle)
39 Interop.Face.GetFaceRect(faceHandle, out var x, out var y, out var width, out var height).
40 ThrowIfError("Failed to get rect for the face info");
42 return new Rectangle(x, y, width, height);
48 /// <value>The region of face in the media.</value>
50 /// The coordinates of the rectangle are orientation-applied values.
52 public Rectangle Rect { get; }
55 /// Gets the id of face info.
57 public string Id { get; }
60 /// Gets the media id that the face info is added.
62 /// <value>The media id that the face info is added.</value>
63 public string MediaInfoId { get; }
66 /// Gets the tag name.
68 /// <value>The tag name of face info.</value>
69 public string Tag { get; }
72 /// Gets the orientation of face info.
74 /// <value>The orientation of face info.</value>
75 public Orientation Orientation { get; }
77 internal static FaceInfo FromHandle(IntPtr handle)
79 return new FaceInfo(handle);
83 /// Returns a string representation of the face info.
85 /// <returns>A string representation of the current face info.</returns>
86 public override string ToString() =>
87 $"Id={Id}, MediaInfoId={MediaInfoId}, Rect=({Rect}), Tag={Tag}";