Enables use of multiple TPUs in OPI5

This commit is contained in:
Tuomas Järvinen
2024-07-27 11:28:47 +03:00
parent 147213cec6
commit 7052a05d55
17 changed files with 336 additions and 65 deletions
+29 -6
View File
@@ -10,7 +10,7 @@ AiEngineGimbalClient::AiEngineGimbalClient(QObject *parent)
// Create server and run it in the new thread.
// Connect all signal and slots here. No need to do the same in AiEngineGimbalServer class.
mGimbalServer = new AiEngineGimbalServer(this);
mGimbalServer = new AiEngineGimbalServer();
QThread *gimbalServerThread = new QThread(this);
mGimbalServer->moveToThread(gimbalServerThread);
@@ -85,6 +85,33 @@ void AiEngineGimbalClient::inferenceResultSlot(AiEngineInferenceResult result)
// TODO!! Just increasing number for testing purposes ATM.
static int index = 0;
// Find best possible target ...
int bestObjectIndex = -1;
float bestObjectProb = -1;
for (int i = 0; i < result.objects.size(); i++) {
const AiEngineObject &object = result.objects[i];
if (object.propability > bestObjectProb) {
bestObjectIndex = i;
bestObjectProb = object.propability;
}
}
// ... if found, then ask camera to zoom to it.
if (bestObjectIndex >= 0) {
const AiEngineObject &object = result.objects[bestObjectIndex];
AiEngineCameraTarget target;
target.rectangle = object.rectangle;
target.index = index++;
qDebug() << "Found best target from index" << bestObjectIndex
<< "Name:" << object.classStr
<< "Probability:" << bestObjectProb;
emit zoomToAiTarget(target);
}
/*
// We got list of all recognized objects, but at least for now we will zoom to all objects at
// once and not for each invidually. Got minimal coordinates which contains the all objects.
AiEngineRectangle groupRect = getGroupCoordinates(result.objects);
@@ -105,9 +132,5 @@ void AiEngineGimbalClient::inferenceResultSlot(AiEngineInferenceResult result)
}
qDebug() << "inferenceResultSlot() Zooming to square top=" << groupRect.top << "x" << groupRect.left << "and bottom:" << groupRect.bottom << "x" << groupRect.right;
AiEngineCameraTarget target;
target.rectangle = groupRect;
target.index = index++;
emit zoomToAiTarget(target);
*/
}