mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 08:06:35 +00:00
Small fixes to AI Controller
- removed QtSerialPort from the Qt CONFIG parameters - remove compiler warnings - reduced logging - fixed FPS to show what AI really analyzed - RTSP reader tries to connect to the stream once per second until it succeeds
This commit is contained in:
+13
-18
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "aiengine.h"
|
||||
#include "aiengineinference.h"
|
||||
#ifdef SAVE_IMAGES
|
||||
#include "aiengineimagesaver.h"
|
||||
#endif
|
||||
|
||||
#if defined(OPI5_BUILD)
|
||||
#include "src-opi5/aiengineinferenceopi5.h"
|
||||
@@ -17,8 +19,11 @@
|
||||
|
||||
|
||||
|
||||
AiEngine::AiEngine(QString modelPath, QObject *parent)
|
||||
: QObject{parent}
|
||||
AiEngine::AiEngine(QString modelPath, QObject *parent) :
|
||||
QObject{parent},
|
||||
mRtspFrameCounter(0),
|
||||
mInferenceFrameCounter(0)
|
||||
|
||||
{
|
||||
mRtspListener = new AiEngineRtspListener(this);
|
||||
connect(mRtspListener, &AiEngineRtspListener::frameReceived, this, &AiEngine::frameReceivedSlot);
|
||||
@@ -69,7 +74,7 @@ AiEngine::AiEngine(QString modelPath, QObject *parent)
|
||||
void AiEngine::start(void)
|
||||
{
|
||||
mRtspListener->startListening();
|
||||
mElapsedTimer.start();
|
||||
mRtspElapsedTimer.start();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,16 +86,15 @@ void AiEngine::stop(void)
|
||||
|
||||
void AiEngine::inferenceResultsReceivedSlot(AiEngineInferenceResult result)
|
||||
{
|
||||
mFrameCounter++;
|
||||
qDebug() << "FPS = " << (mFrameCounter / (mElapsedTimer.elapsed()/1000.0f));
|
||||
//qDebug() << "DEBUG. inference frame counter:" << mFrameCounter;
|
||||
mInferenceFrameCounter++;
|
||||
float fps =mRtspElapsedTimer.elapsed() == 0 ? 0 : (mInferenceFrameCounter / (mRtspElapsedTimer.elapsed()/1000.0f));
|
||||
printf("Analyzed %d/%d frames with AI. FPS=%.1f\n", mInferenceFrameCounter, mRtspFrameCounter, fps);
|
||||
|
||||
//qDebug() << "AiEngine got inference results in thread: " << QThread::currentThreadId();
|
||||
if (mGimbalClient != nullptr) {
|
||||
mGimbalClient->inferenceResultSlot(result);
|
||||
}
|
||||
|
||||
cv::imshow("Received Frame", result.frame);
|
||||
cv::imshow("AI Engine", result.frame);
|
||||
|
||||
#ifdef SAVE_IMAGES
|
||||
static int imageCounter = 0;
|
||||
@@ -103,26 +107,17 @@ void AiEngine::inferenceResultsReceivedSlot(AiEngineInferenceResult result)
|
||||
|
||||
void AiEngine::frameReceivedSlot(cv::Mat frame)
|
||||
{
|
||||
//qDebug() << "AiEngine got frame from RTSP listener in thread: " << QThread::currentThreadId();
|
||||
//cv::imshow("Received Frame", frame);
|
||||
static int framecounter = 0;
|
||||
//qDebug() << "DEBUG. RTSP frame counter:" << framecounter;
|
||||
mRtspFrameCounter++;
|
||||
|
||||
if (mInference->isActive() == false) {
|
||||
//qDebug() << "AiEngine. Inference thread is free. Sending frame to it.";
|
||||
emit inferenceFrame(frame);
|
||||
framecounter++;
|
||||
}
|
||||
#ifdef OPI5_BUILD
|
||||
else if (mInference2->isActive() == false) {
|
||||
//qDebug() << "AiEngine. Inference thread is free. Sending frame to it.";
|
||||
emit inferenceFrame2(frame);
|
||||
framecounter++;
|
||||
}
|
||||
else if (mInference3->isActive() == false) {
|
||||
//qDebug() << "AiEngine. Inference thread is free. Sending frame to it.";
|
||||
emit inferenceFrame3(frame);
|
||||
framecounter++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user