Added functionality to calculate target location.

Added functionality to capture camera frame from RTSP stream.
Refactored code.
Fixed some minor issues.
This commit is contained in:
Nffj84
2024-06-18 17:29:40 +03:00
parent 05722c0e09
commit db2652d979
15 changed files with 689 additions and 264 deletions
+25 -15
View File
@@ -1,11 +1,13 @@
#include <QCoreApplication>
#include <QThread>
#include "serialCommand.h"
#include "serialPort.h"
#include "serialResponse.h"
#include <QCoreApplication>
#include <QThread>
#include "utilsTargetLocation.h"
#include <iostream>
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
// Replace with your actual port name
@@ -26,30 +28,38 @@ int main(int argc, char *argv[]) {
commands.printCommands();
// Get user input
std::cout << "Enter a command (0 to exit): ";
qInfo() << "Enter a command (0 to exit, 1 to run test): ";
int16_t number;
std::cin >> number;
// Check if the input is within the valid range for uint8_t
if (number < 0 || number > commands.getCommandCount() - 1) {
qWarning() << "Number (" << qPrintable(QString::number(number))
<< ") out of range 0 -"
<< qPrintable(QString::number(commands.getCommandCount() - 1));
qWarning() << "Number (" << qPrintable(QString::number(number)) << ") out of range 0 -" << qPrintable(QString::number(commands.getCommandCount() - 1));
continue;
}
// Exit loop if user enters 0
if (number == 0)
if (number == 0) {
break;
} else if (number == 1) {
qInfo() << "Running target location test";
// Example command to send (replace with actual Siyi A8 mini camera
// commands)
QByteArray command = commands.getCommand((uint8_t)number);
serial.sendCommand(command);
UtilsTargetLocation locateTarget(&serial, &commands);
GPSData gpsData = locateTarget.getLocation(200.0, 63.16122286887124, 23.822053704379698, 180.0, 0.0, 0.0, 5.0, 20);
qInfo() << "Altitude: " << gpsData.altitude;
qInfo() << "Latitude: " << gpsData.latitude;
qInfo() << "Longitude: " << gpsData.longitude;
} else {
COMMAND_ID commandId = (COMMAND_ID) number;
// Read response from the camera
QByteArray response = serial.readResponse();
SerialResponse::printResponse(response);
// Example command to send (replace with actual Siyi A8 mini camera commands)
QByteArray command = commands.getCommandByID(commandId);
serial.sendCommand(command);
// Read response from the camera
QByteArray response = serial.readResponse();
SerialResponse::printResponse(response);
}
}
// Close the serial port