From dfe3c7c561474663131e761c11e293b9ad6ed247 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 4 Jul 2024 11:02:18 +0300 Subject: [PATCH] Add support for A8 remote control to opi_rtsp test app --- misc/camera/a8/a8.pro | 8 ++++---- misc/camera/a8/remoteControl.cpp | 2 +- misc/camera/a8_remote/remoteControl.cpp | 2 +- tmp/opi_rtsp/aienginegimbalcontrol.cpp | 23 ++++++++++++++++++++++- tmp/opi_rtsp/aienginegimbalcontrol.h | 2 ++ tmp/opi_rtsp/opi_rtsp.pro | 4 ++-- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/misc/camera/a8/a8.pro b/misc/camera/a8/a8.pro index 6de8ba4..8359cac 100644 --- a/misc/camera/a8/a8.pro +++ b/misc/camera/a8/a8.pro @@ -9,13 +9,13 @@ TARGET = a8 QMAKE_CXXFLAGS = -O0 -g -ggdb -fsanitize=undefined,address,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum QMAKE_LFLAGS = -O0 -g -ggdb -fsanitize=undefined,address,bounds,float-divide-by-zero,integer-divide-by-zero,null,return,signed-integer-overflow,unreachable,shift,alignment,nonnull-attribute,returns-nonnull-attribute,enum -QMAKE_CXX = clang++ -QMAKE_CC = clang +#QMAKE_CXX = clang++ +#QMAKE_CC = clang # Not nice, but for some reason QtCreator doesn't use /usr/lib/ccache/g++ from the PATH linux-g++ { - QMAKE_CXX = clang++ - QMAKE_CC = clang +# QMAKE_CXX = clang++ +# QMAKE_CC = clang } SOURCES += \ diff --git a/misc/camera/a8/remoteControl.cpp b/misc/camera/a8/remoteControl.cpp index 009bc3c..8983515 100644 --- a/misc/camera/a8/remoteControl.cpp +++ b/misc/camera/a8/remoteControl.cpp @@ -84,7 +84,7 @@ void RemoteControl::sendResponse(void) QJsonDocument responseDocument(mResponseObject); std::string response = responseDocument.toJson(QJsonDocument::Compact).toStdString(); - qDebug().noquote().nospace() << "Sending responce: " << response; +// qDebug().noquote().nospace() << "Sending responce: " << response; write(mFifoFdOut, response.c_str(), response.size()); mIsBusy = false; diff --git a/misc/camera/a8_remote/remoteControl.cpp b/misc/camera/a8_remote/remoteControl.cpp index 353e88e..0719680 100644 --- a/misc/camera/a8_remote/remoteControl.cpp +++ b/misc/camera/a8_remote/remoteControl.cpp @@ -89,7 +89,7 @@ void RemoteControl::sendData(uint16_t top, uint16_t left, uint16_t bottom, uint1 QJsonDocument commandDocument(commandObject); std::string command = commandDocument.toJson(QJsonDocument::Compact).toStdString(); write(mFifoFdOut, command.c_str(), command.size()); - qDebug().noquote().nospace() << "Sent: " << command; + //qDebug().noquote().nospace() << "Sent: " << command; } #ifdef FIFO_TEST diff --git a/tmp/opi_rtsp/aienginegimbalcontrol.cpp b/tmp/opi_rtsp/aienginegimbalcontrol.cpp index fb61564..c1b384f 100644 --- a/tmp/opi_rtsp/aienginegimbalcontrol.cpp +++ b/tmp/opi_rtsp/aienginegimbalcontrol.cpp @@ -1,6 +1,7 @@ +#include +#include #include "aienginegimbalcontrol.h" - AiEngineGimbalControl::AiEngineGimbalControl(QObject *parent) : QObject{parent} {} @@ -37,6 +38,10 @@ AiEngineRectangle AiEngineGimbalControl::getGroupCoordinates(QVector 720 || groupRect.bottom > 720) { + return; + } + + if (groupRect.left > 1280 || groupRect.right > 1280) { + return; + } + + if ((groupRect.bottom <= groupRect.top) || (groupRect.right <= groupRect.left)) { + return; + } + + qDebug() << "TUOMAS!! Zooming to square" << groupRect.top << "x" << groupRect.left << "and" << groupRect.bottom << "x" << groupRect.right; + + mRemoteControl.sendData(groupRect.top, groupRect.left, groupRect.left, groupRect.right); } diff --git a/tmp/opi_rtsp/aienginegimbalcontrol.h b/tmp/opi_rtsp/aienginegimbalcontrol.h index 63dc552..610af3f 100644 --- a/tmp/opi_rtsp/aienginegimbalcontrol.h +++ b/tmp/opi_rtsp/aienginegimbalcontrol.h @@ -3,6 +3,7 @@ #include #include #include "aiengineinference.h" +#include "remoteControl.hpp" class AiEngineGimbalControl : public QObject { @@ -12,6 +13,7 @@ public: private: AiEngineRectangle getGroupCoordinates(QVector &objects); + RemoteControl mRemoteControl; public slots: void inferenceResultSlot(AiEngineInferenceResult results); diff --git a/tmp/opi_rtsp/opi_rtsp.pro b/tmp/opi_rtsp/opi_rtsp.pro index a1a8c85..baffd59 100644 --- a/tmp/opi_rtsp/opi_rtsp.pro +++ b/tmp/opi_rtsp/opi_rtsp.pro @@ -10,10 +10,10 @@ HEADERS = $$PWD/*.h opi5 { message("OPI5 build") PKGCONFIG += opencv4 librga stb libturbojpeg - INCLUDEPATH += /usr/include/rga # not correct in pkg-config file + INCLUDEPATH += /usr/include/rga $$PWD/../../misc/camera/a8_remote QMAKE_CXXFLAGS += -DOPI5_BUILD LIBS += /usr/local/lib/librknnrt.so - SOURCES += $$PWD/src-opi5/*.c $$PWD/src-opi5/*.cpp $$PWD/src-opi5/*.cc + SOURCES += $$PWD/src-opi5/*.c $$PWD/src-opi5/*.cpp $$PWD/src-opi5/*.cc $$PWD/../../misc/camera/a8_remote/remoteControl.cpp HEADERS += $$PWD/src-opi5/*.h } else { message("ONNX build")