QPair<QString, QString> FaceManagement::Recognizer::parseIdentity(Identity identity) { QStringList tagParts = identity.attributesMap()[QString::fromLatin1("fullName")].split( QString::fromLatin1("-/-") ); for (QString &part : tagParts) { part.replace(QString::fromLatin1("//"), QString::fromLatin1("/")); } return QPair<QString, QString>(tagParts[0], tagParts[1]); }
void TrainingDB::updateIdentity(const Identity& p) { d->db->execSql("DELETE FROM IdentityAttributes WHERE id=?", p.id()); const QMap<QString, QString> map = p.attributesMap(); QMap<QString, QString>::const_iterator it; for (it = map.begin(); it != map.end(); ++it) { d->db->execSql("INSERT INTO IdentityAttributes (id, attribute, value) VALUES (?, ?,?)", p.id(), it.key(), it.value()); } }
void FaceDb::updateIdentity(const Identity& p) { d->db->execSql(QString::fromLatin1("DELETE FROM IdentityAttributes WHERE id=?;"), p.id()); const QMap<QString, QString> map = p.attributesMap(); QMap<QString, QString>::const_iterator it; for (it = map.constBegin(); it != map.constEnd(); ++it) { d->db->execSql(QString::fromLatin1("INSERT INTO IdentityAttributes (id, attribute, value) VALUES (?, ?,?);"), p.id(), it.key(), it.value()); } }
// Takes care that there may be multiple values of attribute in identity's attributes bool RecognitionDatabase::Private::identityContains(const Identity& identity, const QString& attribute, const QString& value) const { const QMap<QString, QString> map = identity.attributesMap(); QMap<QString, QString>::const_iterator it = map.constFind(attribute); for (; it != map.constEnd() && it.key() == attribute; ++it) { if (it.value() == value) { return true; } } return false; }