중요한 부분은 다음과 같다.
서버와 연결하는 부분
var faceServiceClient = new FaceServiceClient(subscriptionKey);
face를 추출하는 부분
Contract.Face[] faces = await faceServiceClient.DetectAsync(fileStream, false, true, new FaceAttributeType[] { FaceAttributeType.Gender, FaceAttributeType.Age, FaceAttributeType.Smile, FaceAttributeType.Glasses });
돌아가면서 객체 collection에 넣는 모습
foreach (var face in faces)
{
DetectedFaces.Add(new Face()
{
ImagePath = SelectedFile,
Left = face.FaceRectangle.Left,
Top = face.FaceRectangle.Top,
Width = face.FaceRectangle.Width,
Height = face.FaceRectangle.Height,
FaceId = face.FaceId.ToString(),
Gender = face.FaceAttributes.Gender,
Age = string.Format("{0:#} years old", face.FaceAttributes.Age),
IsSmiling = face.FaceAttributes.Smile > 0.0 ? "Smile" : "Not Smile",
Glasses = face.FaceAttributes.Glasses.ToString(),
});
}
{"FaceId":"8e81344d-f275-4d9f-be83-4baf98d61eba","FaceRectangle":{"Width":216,"Height":216,"Left":73,"Top":202},"FaceLandmarks":{"PupilLeft":{"X":142.6,"Y":257.4},"PupilRight":{"X":233.1,"Y":259.6},"NoseTip":{"X":168.4,"Y":318.9},"MouthLeft":{"X":140.4,"Y":361.3},"MouthRight":{"X":223.9,"Y":363.6},"EyebrowLeftOuter":{"X":105.6,"Y":229.9},"EyebrowLeftInner":{"X":158.6,"Y":235.1},"EyeLeftOuter":{"X":124.0,"Y":256.4},"EyeLeftTop":{"X":138.8,"Y":252.3},"EyeLeftBottom":{"X":136.7,"Y":266.6},"EyeLeftInner":{"X":153.8,"Y":261.7},"EyebrowRightInner":{"X":202.3,"Y":230.7},"EyebrowRightOuter":{"X":273.7,"Y":234.6},"EyeRightInner":{"X":214.5,"Y":263.7},"EyeRightTop":{"X":230.6,"Y":253.0},"EyeRightBottom":{"X":231.9,"Y":268.3},"EyeRightOuter":{"X":249.0,"Y":260.8},"NoseRootLeft":{"X":167.0,"Y":264.8},"NoseRootRight":{"X":193.4,"Y":265.6},"NoseLeftAlarTop":{"X":158.1,"Y":301.3},"NoseRightAlarTop":{"X":198.1,"Y":303.4},"NoseLeftAlarOutTip":{"X":148.2,"Y":318.6},"NoseRightAlarOutTip":{"X":205.7,"Y":324.7},"UpperLipTop":{"X":174.0,"Y":354.9},"UpperLipBottom":{"X":173.2,"Y":364.6},"UnderLipTop":{"X":173.5,"Y":368.8},"UnderLipBottom":{"X":173.2,"Y":382.6}},"FaceAttributes":{"Age":24.2,"Gender":"male","HeadPose":null,"Smile":0.02,"FacialHair":null,"Glasses":"NoGlasses"}}
'소프트웨어 개발 > C' 카테고리의 다른 글
C++ Visual Studio Code 에서 실행 (0) | 2017.08.05 |
---|---|
Microsoft Face API를 이용한 얼굴 세부 인식기 개발 (0) | 2016.04.03 |
C# 기억해두어야 할것 (0) | 2016.04.03 |
[링크] 시샵 강좌 (0) | 2016.04.03 |
[링크] 마이크로소프트 Face API C#에서 이용 (0) | 2016.03.20 |