Merge for new attributes support in Build2017 (#11)
* Add new attributes contract * Add ListPerson interface and deprecated GetPersons * Fix comments * Support EnumString convert by Gson * Display new attributes in Detection demo page * Change version for Build2017 * Support list persons and personGroups by parameter "top" only * Fix comments and use TextUtils join * Fix comment that using array * Refine new atrributes' comment * Support more attributes display in demo * Display glasses type in demo
This commit is contained in:
Родитель
f4669810a2
Коммит
994f0b360a
|
@ -26,7 +26,7 @@ group = "com.microsoft.projectoxford"
|
|||
// Artifact name is the name of the technology
|
||||
archivesBaseName = "face"
|
||||
// Update your version
|
||||
version = "1.2.5"
|
||||
version = "1.3.0"
|
||||
|
||||
// Upload artifacts to maven central repository staging servers
|
||||
uploadArchives {
|
||||
|
|
|
@ -123,6 +123,55 @@ public interface FaceServiceClient {
|
|||
public String toString() {
|
||||
return "emotion";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses hair type
|
||||
*/
|
||||
Hair {
|
||||
public String toString() { return "hair"; }
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses makeup type
|
||||
*/
|
||||
Makeup {
|
||||
public String toString() { return "makeup"; }
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses occlusion type
|
||||
*/
|
||||
Occlusion {
|
||||
public String toString() { return "occlusion"; }
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses accessories type
|
||||
*/
|
||||
Accessories {
|
||||
public String toString() { return "accessories"; }
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses noise type
|
||||
*/
|
||||
Noise {
|
||||
public String toString() { return "noise"; }
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses exposure type
|
||||
*/
|
||||
Exposure {
|
||||
public String toString() { return "exposure"; }
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyses blur type
|
||||
*/
|
||||
Blur {
|
||||
public String toString() { return "blur"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,6 +348,15 @@ public interface FaceServiceClient {
|
|||
*/
|
||||
PersonGroup[] listPersonGroups(String start) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* List the fist "top" of person groups.
|
||||
* @param top The number of person groups to list.
|
||||
* @return Person group entity array.
|
||||
* @throws ClientException
|
||||
* @throws IOException
|
||||
*/
|
||||
PersonGroup[] listPersonGroups(int top) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* List the fist "top" of person groups whose Id is lager than "start".
|
||||
* @return Person group entity array.
|
||||
|
@ -329,13 +387,55 @@ public interface FaceServiceClient {
|
|||
Person getPerson(String personGroupId, UUID personId) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* Gets all persons inside a person group.
|
||||
* Gets 1000 persons inside a person group.
|
||||
* @param personGroupId The person group id.
|
||||
* @return The person entity array.
|
||||
* @throws ClientException
|
||||
* @throws IOException
|
||||
* @deprecated use {@link #listPersons(String)} l} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Person[] getPersons(String personGroupId) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* List the fist "top" of persons whose Id is lager than "start".
|
||||
* @param personGroupId The person group id.
|
||||
* @param start The persons Id bar, list persons whose Id is lager than "start.
|
||||
* @param top The number of persons to list.
|
||||
* @return The person entity array.
|
||||
* @throws ClientException
|
||||
* @throws IOException
|
||||
*/
|
||||
Person[] listPersons(String personGroupId, String start, int top) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* List the fist "top" of persons whose Id is lager than "start".
|
||||
* @param personGroupId The person group id.
|
||||
* @param start The persons Id bar, list persons whose Id is lager than "start.
|
||||
* @return The person entity array.
|
||||
* @throws ClientException
|
||||
* @throws IOException
|
||||
*/
|
||||
Person[] listPersons(String personGroupId, String start) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* List the fist "top" of persons.
|
||||
* @param personGroupId The person group id.
|
||||
* @param top The number of persons to list.
|
||||
* @return The person entity array.
|
||||
* @throws ClientException
|
||||
* @throws IOException
|
||||
*/
|
||||
Person[] listPersons(String personGroupId, int top) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* List the fist 1000 persons.
|
||||
* @param personGroupId The person group id.
|
||||
* @return The person entity array.
|
||||
* @throws ClientException
|
||||
* @throws IOException
|
||||
*/
|
||||
Person[] getPersons(String personGroupId) throws ClientException, IOException;
|
||||
Person[] listPersons(String personGroupId) throws ClientException, IOException;
|
||||
|
||||
/**
|
||||
* Adds a face to a person.
|
||||
|
|
|
@ -297,6 +297,11 @@ public class FaceServiceRestClient implements FaceServiceClient {
|
|||
return listPersonGroups(start, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersonGroup[] listPersonGroups(int top) throws ClientException, IOException{
|
||||
return listPersonGroups("", top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersonGroup[] listPersonGroups() throws ClientException, IOException {
|
||||
return listPersonGroups("", 1000);
|
||||
|
@ -325,11 +330,17 @@ public class FaceServiceRestClient implements FaceServiceClient {
|
|||
return mGson.fromJson(json, Person.class);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Person[] getPersons(String personGroupId) throws ClientException, IOException {
|
||||
return listPersons(personGroupId, "", 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Person[] listPersons(String personGroupId, String start, int top) throws ClientException, IOException {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
|
||||
String uri = String.format("%s/%s/%s/%s", mServiceHost, PERSON_GROUPS_QUERY, personGroupId, PERSONS_QUERY);
|
||||
String uri = String.format("%s/%s/%s/%s?start=%s&top=%s", mServiceHost, PERSON_GROUPS_QUERY, personGroupId, PERSONS_QUERY, start, top);
|
||||
String json = (String)mRestCall.request(uri, RequestMethod.GET, params, null);
|
||||
Type listType = new TypeToken<List<Person>>() {
|
||||
}.getType();
|
||||
|
@ -337,6 +348,20 @@ public class FaceServiceRestClient implements FaceServiceClient {
|
|||
return result.toArray(new Person[result.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Person[] listPersons(String personGroupId, String start) throws ClientException, IOException {
|
||||
return listPersons(personGroupId, start, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Person[] listPersons(String personGroupId, int top) throws ClientException, IOException {
|
||||
return listPersons(personGroupId, "", top);
|
||||
}
|
||||
|
||||
public Person[] listPersons(String personGroupId) throws ClientException, IOException {
|
||||
return listPersons(personGroupId, "", 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddPersistedFaceResult addPersonFace(String personGroupId, UUID personId, String url, String userData, FaceRectangle targetFace) throws ClientException, IOException {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Accessory class contains accessory information
|
||||
*/
|
||||
public class Accessory {
|
||||
/**
|
||||
* Accessory types
|
||||
*/
|
||||
public enum AccessoryType {
|
||||
@SerializedName("headwear")
|
||||
Headwear,
|
||||
@SerializedName("glasses")
|
||||
Glasses,
|
||||
@SerializedName("mask")
|
||||
Mask
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating the accessory type
|
||||
*/
|
||||
public AccessoryType type;
|
||||
|
||||
/**
|
||||
* Indicating the confidence for accessory type
|
||||
*/
|
||||
public double confidence;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Blur class contains blur information
|
||||
*/
|
||||
public class Blur {
|
||||
/**
|
||||
* Definition of blur level
|
||||
*/
|
||||
public enum BlurLevel{
|
||||
/**
|
||||
* Low blur level indicating a clear face image
|
||||
*/
|
||||
@SerializedName("low")
|
||||
Low,
|
||||
/**
|
||||
* Medium blur level indicating a slightly blurry face image
|
||||
*/
|
||||
@SerializedName("medium")
|
||||
Medium,
|
||||
/**
|
||||
* High blur level indicating a extremely blurry face image
|
||||
*/
|
||||
@SerializedName("high")
|
||||
High
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating the blur level of face image
|
||||
*/
|
||||
public BlurLevel blurLevel;
|
||||
|
||||
/**
|
||||
* Blur value is in range [0, 1]. Larger value means the face image is more blurry.
|
||||
* [0, 0.25) is low blur level.
|
||||
* [0.25, 0.75) is medium blur level.
|
||||
* [0.75, 1] is high blur level.
|
||||
*/
|
||||
public double value;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Exposure class contains exposure information
|
||||
*/
|
||||
public class Exposure {
|
||||
/**
|
||||
* Definition of exposure level
|
||||
*/
|
||||
public enum ExposureLevel{
|
||||
/**
|
||||
* Indicating face image is in under exposure
|
||||
*/
|
||||
@SerializedName("underExposure")
|
||||
UnderExposure,
|
||||
/**
|
||||
* Indicating face image is in good exposure
|
||||
*/
|
||||
@SerializedName("goodExposure")
|
||||
GoodExposure,
|
||||
/**
|
||||
* Indicating face image is in over exposure
|
||||
*/
|
||||
@SerializedName("overExposure")
|
||||
OverExposure
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating exposure level of face image
|
||||
*/
|
||||
public ExposureLevel exposureLevel;
|
||||
|
||||
/**
|
||||
* Exposure value is in range [0, 1]. Larger value means the face image is more brighter.
|
||||
* [0, 0.25) is under exposure.
|
||||
* [0.25, 0.75) is good exposure.
|
||||
* [0.75, 1] is over exposure.
|
||||
*/
|
||||
public double value;
|
||||
}
|
|
@ -46,4 +46,18 @@ public class FaceAttribute {
|
|||
public Glasses glasses;
|
||||
|
||||
public Emotion emotion;
|
||||
|
||||
public Blur blur;
|
||||
|
||||
public Exposure exposure;
|
||||
|
||||
public Noise noise;
|
||||
|
||||
public Makeup makeup;
|
||||
|
||||
public Accessory[] accessories;
|
||||
|
||||
public Occlusion occlusion;
|
||||
|
||||
public Hair hair;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Hair class contains hair color information
|
||||
*/
|
||||
public class Hair {
|
||||
/**
|
||||
* Indicating the confidence of a bald head
|
||||
*/
|
||||
public double bald;
|
||||
|
||||
/**
|
||||
* Indicating whether hair is occluded or not
|
||||
*/
|
||||
public boolean invisible;
|
||||
|
||||
/**
|
||||
* Hair color details
|
||||
*/
|
||||
public static class HairColor{
|
||||
/**
|
||||
* Hair color type
|
||||
*/
|
||||
public enum HairColorType {
|
||||
@SerializedName("unknown")
|
||||
Unknown,
|
||||
@SerializedName("white")
|
||||
White,
|
||||
@SerializedName("gray")
|
||||
Gray,
|
||||
@SerializedName("blond")
|
||||
Blond,
|
||||
@SerializedName("brown")
|
||||
Brown,
|
||||
@SerializedName("red")
|
||||
Red,
|
||||
@SerializedName("black")
|
||||
Black,
|
||||
@SerializedName("other")
|
||||
Other
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating the hair color type
|
||||
*/
|
||||
public HairColorType color;
|
||||
|
||||
/**
|
||||
* Indicating the confidence for hair color type
|
||||
*/
|
||||
public double confidence;
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicating all possible hair colors with confidences
|
||||
*/
|
||||
public HairColor[] hairColor;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
/**
|
||||
* Makeup contains makeup information
|
||||
*/
|
||||
public class Makeup {
|
||||
/**
|
||||
* Indicating whether eye has makeup or not
|
||||
*/
|
||||
public boolean eyeMakeup;
|
||||
|
||||
/**
|
||||
* Indicating whether lip has makeup or not
|
||||
*/
|
||||
public boolean lipMakeup;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Noise class contains noise information
|
||||
*/
|
||||
public class Noise {
|
||||
/**
|
||||
* Definition of noise level
|
||||
*/
|
||||
public enum NoiseLevel {
|
||||
/**
|
||||
* Low noise level indicating a clear face image
|
||||
*/
|
||||
@SerializedName("low")
|
||||
Low,
|
||||
/**
|
||||
* Medium noise level indicating a slightly noisy face image
|
||||
*/
|
||||
@SerializedName("medium")
|
||||
Medium,
|
||||
/**
|
||||
* High noise level indicating a extremely noisy face image
|
||||
*/
|
||||
@SerializedName("high")
|
||||
High
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating noise level of face image
|
||||
*/
|
||||
public NoiseLevel noiseLevel;
|
||||
|
||||
/**
|
||||
* Noise value is in range [0, 1]. Larger value means the face image is more noisy.
|
||||
* [0, 0.3) is low noise level.
|
||||
* [0.3, 0.7) is medium noise level.
|
||||
* [0.7, 1] is high noise level.
|
||||
*/
|
||||
public double value;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services
|
||||
//
|
||||
// Microsoft Cognitive Services (formerly Project Oxford) GitHub:
|
||||
// https://github.com/Microsoft/Cognitive-Face-Android
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// MIT License:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
package com.microsoft.projectoxford.face.contract;
|
||||
|
||||
/**
|
||||
* Occlusion class contains occlusion information
|
||||
*/
|
||||
public class Occlusion {
|
||||
/**
|
||||
* Indicating whether forehead is occluded or not
|
||||
*/
|
||||
public boolean foreheadOccluded;
|
||||
|
||||
/**
|
||||
* Indicating whether eye is occluded or not
|
||||
*/
|
||||
public boolean eyeOccluded;
|
||||
|
||||
/**
|
||||
* Indicating whether mouth is occluded or not
|
||||
*/
|
||||
public boolean mouthOccluded;
|
||||
}
|
|
@ -24,7 +24,7 @@ dependencies {
|
|||
|
||||
// Use the following line to include client library for Face API from Maven Central Repository
|
||||
|
||||
compile 'com.microsoft.projectoxford:face:1.2.5'
|
||||
compile 'com.microsoft.projectoxford:face:1.3.0'
|
||||
compile 'com.android.support:appcompat-v7:22.1.0'
|
||||
compile 'com.google.code.gson:gson:2.3.1'
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -55,6 +56,13 @@ import com.microsoft.projectoxford.face.contract.Emotion;
|
|||
import com.microsoft.projectoxford.face.contract.Face;
|
||||
import com.microsoft.projectoxford.face.contract.FacialHair;
|
||||
import com.microsoft.projectoxford.face.contract.HeadPose;
|
||||
import com.microsoft.projectoxford.face.contract.Accessory;
|
||||
import com.microsoft.projectoxford.face.contract.Blur;
|
||||
import com.microsoft.projectoxford.face.contract.Exposure;
|
||||
import com.microsoft.projectoxford.face.contract.Hair;
|
||||
import com.microsoft.projectoxford.face.contract.Makeup;
|
||||
import com.microsoft.projectoxford.face.contract.Noise;
|
||||
import com.microsoft.projectoxford.face.contract.Occlusion;
|
||||
import com.microsoft.projectoxford.face.samples.R;
|
||||
import com.microsoft.projectoxford.face.samples.helper.ImageHelper;
|
||||
import com.microsoft.projectoxford.face.samples.helper.LogHelper;
|
||||
|
@ -96,7 +104,14 @@ public class DetectionActivity extends AppCompatActivity {
|
|||
FaceServiceClient.FaceAttributeType.Glasses,
|
||||
FaceServiceClient.FaceAttributeType.FacialHair,
|
||||
FaceServiceClient.FaceAttributeType.Emotion,
|
||||
FaceServiceClient.FaceAttributeType.HeadPose
|
||||
FaceServiceClient.FaceAttributeType.HeadPose,
|
||||
FaceServiceClient.FaceAttributeType.Accessories,
|
||||
FaceServiceClient.FaceAttributeType.Blur,
|
||||
FaceServiceClient.FaceAttributeType.Exposure,
|
||||
FaceServiceClient.FaceAttributeType.Hair,
|
||||
FaceServiceClient.FaceAttributeType.Makeup,
|
||||
FaceServiceClient.FaceAttributeType.Noise,
|
||||
FaceServiceClient.FaceAttributeType.Occlusion
|
||||
});
|
||||
} catch (Exception e) {
|
||||
mSucceed = false;
|
||||
|
@ -371,22 +386,77 @@ public class DetectionActivity extends AppCompatActivity {
|
|||
|
||||
// Show the face details.
|
||||
DecimalFormat formatter = new DecimalFormat("#0.0");
|
||||
String face_description = String.format("Age: %s\nGender: %s\nSmile: %s\nGlasses: %s\nFacialHair: %s\nHeadPose: %s",
|
||||
String face_description = String.format("Age: %s Gender: %s\nHair: %s FacialHair: %s\nMakeup: %s %s\nForeheadOccluded: %s Blur: %s\nEyeOccluded: %s %s\n" +
|
||||
"MouthOccluded: %s Noise: %s\nGlassesType: %s\nHeadPose: %s\nAccessories: %s",
|
||||
faces.get(position).faceAttributes.age,
|
||||
faces.get(position).faceAttributes.gender,
|
||||
faces.get(position).faceAttributes.smile,
|
||||
faces.get(position).faceAttributes.glasses,
|
||||
getHair(faces.get(position).faceAttributes.hair),
|
||||
getFacialHair(faces.get(position).faceAttributes.facialHair),
|
||||
getMakeup((faces.get(position)).faceAttributes.makeup),
|
||||
getEmotion(faces.get(position).faceAttributes.emotion),
|
||||
getHeadPose(faces.get(position).faceAttributes.headPose)
|
||||
faces.get(position).faceAttributes.occlusion.foreheadOccluded,
|
||||
faces.get(position).faceAttributes.blur.blurLevel,
|
||||
faces.get(position).faceAttributes.occlusion.eyeOccluded,
|
||||
faces.get(position).faceAttributes.exposure.exposureLevel,
|
||||
faces.get(position).faceAttributes.occlusion.mouthOccluded,
|
||||
faces.get(position).faceAttributes.noise.noiseLevel,
|
||||
faces.get(position).faceAttributes.glasses,
|
||||
getHeadPose(faces.get(position).faceAttributes.headPose),
|
||||
getAccessories(faces.get(position).faceAttributes.accessories)
|
||||
);
|
||||
((TextView) convertView.findViewById(R.id.text_detected_face)).setText(face_description);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private String getFacialHair(FacialHair facialHair)
|
||||
{
|
||||
private String getHair(Hair hair) {
|
||||
if (hair.hairColor.length == 0)
|
||||
{
|
||||
if (hair.invisible)
|
||||
return "Invisible";
|
||||
else
|
||||
return "Bald";
|
||||
}
|
||||
else
|
||||
{
|
||||
int maxConfidenceIndex = 0;
|
||||
double maxConfidence = 0.0;
|
||||
|
||||
for (int i = 0; i < hair.hairColor.length; ++i)
|
||||
{
|
||||
if (hair.hairColor[i].confidence > maxConfidence)
|
||||
{
|
||||
maxConfidence = hair.hairColor[i].confidence;
|
||||
maxConfidenceIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
return hair.hairColor[maxConfidenceIndex].color.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private String getMakeup(Makeup makeup) {
|
||||
return (makeup.eyeMakeup || makeup.lipMakeup) ? "Yes" : "No" ;
|
||||
}
|
||||
|
||||
private String getAccessories(Accessory[] accessories) {
|
||||
if (accessories.length == 0)
|
||||
{
|
||||
return "NoAccessories";
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] accessoriesList = new String[accessories.length];
|
||||
for (int i = 0; i < accessories.length; ++i)
|
||||
{
|
||||
accessoriesList[i] = accessories[i].type.toString();
|
||||
}
|
||||
|
||||
return TextUtils.join(",", accessoriesList);
|
||||
}
|
||||
}
|
||||
|
||||
private String getFacialHair(FacialHair facialHair) {
|
||||
return (facialHair.moustache + facialHair.beard + facialHair.sideburns > 0) ? "Yes" : "No";
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче