mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 19:16:39 +00:00
Addd initial AiEngineGimbalControl class
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include "aienginegimbalcontrol.h"
|
||||
|
||||
|
||||
AiEngineGimbalControl::AiEngineGimbalControl(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
|
||||
AiEngineRectangle AiEngineGimbalControl::getGroupCoordinates(QVector<AiEngineObject> &objects)
|
||||
{
|
||||
AiEngineRectangle groupRectangle;
|
||||
groupRectangle.top = 1000000;
|
||||
groupRectangle.left = 1000000;
|
||||
groupRectangle.bottom = 0;
|
||||
groupRectangle.right = 0;
|
||||
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
const AiEngineRectangle &objectRectangle = objects[i].rectangle;
|
||||
|
||||
if (objectRectangle.top < groupRectangle.top) {
|
||||
groupRectangle.top = objectRectangle.top;
|
||||
}
|
||||
if (objectRectangle.left < groupRectangle.left) {
|
||||
groupRectangle.left = objectRectangle.left;
|
||||
}
|
||||
if (objectRectangle.bottom > groupRectangle.bottom) {
|
||||
groupRectangle.bottom = objectRectangle.bottom;
|
||||
}
|
||||
if (objectRectangle.right > groupRectangle.right) {
|
||||
groupRectangle.right = objectRectangle.right;
|
||||
}
|
||||
}
|
||||
|
||||
return groupRectangle;
|
||||
}
|
||||
|
||||
|
||||
void AiEngineGimbalControl::inferenceResultSlot(AiEngineInferenceResult result)
|
||||
{
|
||||
// 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);
|
||||
|
||||
// AI did inference with 640x360 resolution. Scale back to A8's 1280x720 resolution.
|
||||
groupRect.top *= 2;
|
||||
groupRect.left *= 2;
|
||||
groupRect.bottom *= 2;
|
||||
groupRect.right *= 2;
|
||||
}
|
||||
Reference in New Issue
Block a user