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 the 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 information.
57 /// <value>The unique ID of face information.</value>
58 public string Id { get; }
61 /// Gets the media ID that the face information is added.
63 /// <value>The media ID that the face information is added.</value>
64 public string MediaInfoId { get; }
69 /// <value>The tag of face information.</value>
70 public string Tag { get; }
73 /// Gets the orientation of face information.
75 /// <value>The orientation of face information.</value>
76 public Orientation Orientation { get; }
78 internal static FaceInfo FromHandle(IntPtr handle)
80 return new FaceInfo(handle);
84 /// Returns a string representation of the face information.
86 /// <returns>A string representation of the current face info.</returns>
87 public override string ToString() =>
88 $"Id={Id}, MediaInfoId={MediaInfoId}, Rect=({Rect}), Tag={Tag}";