Skip to content

Commit 544442e

Browse files
committed
Server: add option to disable face recognition
1 parent 7058678 commit 544442e

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

server/source/Client/Client.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ void Client::processTextMessage(const QString& string)
173173
sendCommand(Command::SETTING_DETERMINISTICOBJECTDETECTION, settings.deterministicObjectDetection.load());
174174
break;
175175
}
176+
177+
case (unsigned int)Command::SETTING_FACERECOGNITIONENABLED:
178+
{
179+
settings.faceRecognitionEnabled = context.toBool();
180+
181+
sendCommand(Command::SETTING_FACERECOGNITIONENABLED, settings.faceRecognitionEnabled.load());
182+
break;
183+
}
176184
// implement later ...
177185
}
178186
}

server/source/Client/Client.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct Settings
2828
std::atomic<bool> objectDetectionEnabled = true;
2929
std::atomic<size_t> labelCount = 5;
3030
std::atomic<bool> deterministicObjectDetection = false;
31+
std::atomic<bool> faceRecognitionEnabled = true;
3132
};
3233

3334
class Client : public QObject
@@ -43,7 +44,8 @@ class Client : public QObject
4344
MESSAGE_TAG_OBJECT = 4,
4445
SETTING_OBJDETECTIONENABLED = 5,
4546
SETTING_LABELCOUNT = 6,
46-
SETTING_DETERMINISTICOBJECTDETECTION = 7
47+
SETTING_DETERMINISTICOBJECTDETECTION = 7,
48+
SETTING_FACERECOGNITIONENABLED = 8
4749
};
4850

4951
Settings settings;

server/source/DLIBWorker/DLIBWorker.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,31 +297,35 @@ void DLIBWorker::process(const QByteArray& buffer)
297297
emit doneObject(result);
298298
}
299299

300-
auto faces = findFaces(img);
301-
302-
rectangle rect;
303-
for (const auto& face : referenceFaces)
300+
if (m_settings->faceRecognitionEnabled)
304301
{
305-
faces.push_back(make_tuple(get<0>(face), rect, get<2>(face)));
306-
}
302+
auto faces = findFaces(img);
307303

308-
auto graph = createGraph(faces, m_threshold);
304+
rectangle rect;
305+
for (const auto& face : referenceFaces)
306+
{
307+
faces.push_back(make_tuple(get<0>(face), rect, get<2>(face)));
308+
}
309309

310-
auto clusters = cluster(graph, faces);
310+
auto graph = createGraph(faces, m_threshold);
311311

312-
QVector<QPair<QRect, QString>> linearFaces;
312+
auto clusters = cluster(graph, faces);
313313

314-
for (const auto& it : clusters)
315-
{
316-
QString str = it.first;
317-
for (const auto& it2 : it.second)
314+
QVector<QPair<QRect, QString>> linearFaces;
315+
316+
for (const auto& it : clusters)
318317
{
319-
linearFaces.push_back(qMakePair(QRect(it2.left(), it2.top(), it2.width(), it2.height()), str));
318+
QString str = it.first;
319+
for (const auto& it2 : it.second)
320+
{
321+
linearFaces.push_back(qMakePair(QRect(it2.left(), it2.top(), it2.width(), it2.height()), str));
322+
}
320323
}
324+
325+
emit doneFace(linearFaces);
321326
}
322327

323328
m_busy = false;
324-
emit doneFace(linearFaces);
325329
}
326330
catch(const std::exception& e)
327331
{

0 commit comments

Comments
 (0)