#include "aienginegimbalcontrol.h" AiEngineGimbalControl::AiEngineGimbalControl(QObject *parent) : QObject{parent} {} AiEngineRectangle AiEngineGimbalControl::getGroupCoordinates(QVector &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; }