public static FaceAttributes ToFaceAttributes(this MPOFaceAttributes attrs) { return(new FaceAttributes { Age = attrs.Age.AsFloatSafe(), SmileIntensity = attrs.Smile.AsFloatSafe(), Gender = attrs.Gender, Glasses = attrs.Glasses, HeadPose = attrs.HeadPose.ToFaceHeadPose(), Emotion = attrs.Emotion.ToFaceEmotion(), Hair = attrs.Hair.ToHair(), Makeup = attrs.Makeup.ToMakeup(), Occlusion = attrs.Occlusion.ToOcclusion(), Accessories = attrs.Accessories.ToAccessories(), Blur = attrs.Blur.ToBlur(), Exposure = attrs.Exposure.ToExposure(), Noise = attrs.Noise.ToNoise() }); }
internal static FaceAttributes ToFaceAttributes(this MPOFaceAttributes attrs, FaceAttributeType [] attributes = null) { if (attributes?.Length > 0) { var faceAttributes = new FaceAttributes(); foreach (var attr in attributes) { switch (attr) { case FaceAttributeType.Age: faceAttributes.Age = attrs.Age.AsFloatSafe(); break; case FaceAttributeType.Smile: faceAttributes.SmileIntensity = attrs.Smile.AsFloatSafe(); break; case FaceAttributeType.Gender: faceAttributes.Gender = attrs.Gender; break; case FaceAttributeType.Glasses: faceAttributes.Glasses = attrs.Glasses.AsEnum <Glasses> (); break; case FaceAttributeType.FacialHair: faceAttributes.FacialHair = attrs.FacialHair.ToFacialHair(); break; case FaceAttributeType.HeadPose: faceAttributes.HeadPose = attrs.HeadPose.ToFaceHeadPose(); break; case FaceAttributeType.Emotion: faceAttributes.Emotion = attrs.Emotion.ToFaceEmotion(); break; case FaceAttributeType.Hair: faceAttributes.Hair = attrs.Hair.ToHair(); break; case FaceAttributeType.Makeup: faceAttributes.Makeup = attrs.Makeup.ToMakeup(); break; case FaceAttributeType.Occlusion: faceAttributes.Occlusion = attrs.Occlusion.ToOcclusion(); break; case FaceAttributeType.Accessories: faceAttributes.Accessories = attrs.Accessories.ToAccessories(); break; case FaceAttributeType.Blur: faceAttributes.Blur = attrs.Blur.ToBlur(); break; case FaceAttributeType.Exposure: faceAttributes.Exposure = attrs.Exposure.ToExposure(); break; case FaceAttributeType.Noise: faceAttributes.Noise = attrs.Noise.ToNoise(); break; } } return(faceAttributes); } return(null); }