public virtual Face[] GetRecognizedFaces() { sbyte[] bytes = GetByteArray(TagFaceRecognitionInfo); if (bytes == null) { return null; } RandomAccessReader reader = new ByteArrayReader(bytes); reader.SetMotorolaByteOrder(false); try { int faceCount = reader.GetUInt16(0); if (faceCount == 0) { return null; } Face[] faces = new Face[faceCount]; for (int i = 0; i < faceCount; i++) { int offset = 4 + i * 44; string name = Sharpen.Extensions.Trim(reader.GetString(offset, 20, "ASCII")); string age = Sharpen.Extensions.Trim(reader.GetString(offset + 28, 20, "ASCII")); faces[i] = new Face(reader.GetUInt16(offset + 20), reader.GetUInt16(offset + 22), reader.GetUInt16(offset + 24), reader.GetUInt16(offset + 26), name, Age.FromPanasonicString(age)); } return faces; } catch (IOException) { return null; } }
public virtual Face[] GetDetectedFaces() { sbyte[] bytes = GetByteArray(TagFaceDetectionInfo); if (bytes == null) { return null; } RandomAccessReader reader = new ByteArrayReader(bytes); reader.SetMotorolaByteOrder(false); try { int faceCount = reader.GetUInt16(0); if (faceCount == 0) { return null; } Face[] faces = new Face[faceCount]; for (int i = 0; i < faceCount; i++) { int offset = 2 + i * 8; faces[i] = new Face(reader.GetUInt16(offset), reader.GetUInt16(offset + 2), reader.GetUInt16(offset + 4), reader.GetUInt16(offset + 6), null, null); } return faces; } catch (IOException) { return null; } }