140 lines
3.8 KiB
C++
140 lines
3.8 KiB
C++
#ifndef PARKINGSPACEGUIDE_DETECTPRESENTER_H
|
|
#define PARKINGSPACEGUIDE_DETECTPRESENTER_H
|
|
|
|
#include <memory>
|
|
|
|
#include <QByteArray>
|
|
#include <QImage>
|
|
#include <QRectF>
|
|
#include <QString>
|
|
#include <QVector>
|
|
|
|
#include "IRsLidarDevice.h"
|
|
#include "IYParkingSpaceGuideStatus.h"
|
|
|
|
class AapgsModelClassifier;
|
|
class PersionModelDetector;
|
|
struct PersonDetectionResult;
|
|
|
|
enum class AirplanePresenceState
|
|
{
|
|
NotDetected,
|
|
Detected,
|
|
GateBlocked,
|
|
ViewBlocked
|
|
};
|
|
|
|
struct AirplanePresenceResult
|
|
{
|
|
AirplanePresenceState state = AirplanePresenceState::NotDetected;
|
|
QString message;
|
|
};
|
|
|
|
struct ParkingGuideAlgorithmState
|
|
{
|
|
QByteArray algorithmData;
|
|
QString selectedModelType;
|
|
QString recognizedModelType;
|
|
double modelConfidence = 0.0;
|
|
bool modelVerified = false;
|
|
bool modelRecognitionComplete = false;
|
|
bool modelVerificationSupported = true;
|
|
bool modelRecognitionInProgress = false;
|
|
int modelRecognitionAttempts = 0;
|
|
|
|
qint64 lastPersonDetectionTimestampMs = -1;
|
|
int personStableFrameCount = 0;
|
|
int personCount = 0;
|
|
double personConfidence = 0.0;
|
|
bool personInChockRegion = false;
|
|
bool chocksConfirmed = false;
|
|
|
|
bool hasMeasurement = false;
|
|
qint64 lastTimestampMs = 0;
|
|
double lastDistance = 0.0;
|
|
double lastDeviation = 0.0;
|
|
double lastAngle = 0.0;
|
|
double lastNoseX = 0.0;
|
|
double lastNoseY = 0.0;
|
|
double lastNoseZ = 0.0;
|
|
double filteredApproachSpeed = 0.0;
|
|
int successfulFrameCount = 0;
|
|
int errorFrameCount = 0;
|
|
int lostFrameCount = 0;
|
|
int stoppedFrameCount = 0;
|
|
int stoppedShortFrameCount = 0;
|
|
int completedHoldFrameCount = 0;
|
|
int lastGuideStateCode = static_cast<int>(ParkingGuideState::Waiting);
|
|
bool centerLineAligned = false;
|
|
bool stopPositionReached = false;
|
|
bool dockingCompleted = false;
|
|
};
|
|
|
|
struct ParkingGuideAlgorithmControl
|
|
{
|
|
ParkingGuideAlgorithmState nextState;
|
|
QByteArray recognitionContext;
|
|
int planeLocalizationErrorCode = 0;
|
|
QString planeLocalizationMessage;
|
|
bool needModelRecognition = false;
|
|
};
|
|
|
|
struct ModelRecognitionResult
|
|
{
|
|
QString modelType;
|
|
double confidence = 0.0;
|
|
QString message;
|
|
bool verified = false;
|
|
bool recognitionComplete = false;
|
|
bool verificationSupported = true;
|
|
|
|
bool IsVerified(double minimumConfidence) const;
|
|
};
|
|
|
|
class DetectPresenter
|
|
{
|
|
public:
|
|
DetectPresenter();
|
|
~DetectPresenter();
|
|
|
|
DetectPresenter(const DetectPresenter&) = delete;
|
|
DetectPresenter& operator=(const DetectPresenter&) = delete;
|
|
|
|
static QString GetAlgoVersion();
|
|
|
|
int DetectAirplanePresence(const RsCloudData& cloud,
|
|
const VrAlgorithmParams& algorithmParams,
|
|
AirplanePresenceResult& result);
|
|
|
|
int DetectParkingSpaceGuide(const RsCloudData& cloud,
|
|
const VrAlgorithmParams& algorithmParams,
|
|
qint64 frameTimestampMs,
|
|
const ParkingGuideAlgorithmState& previousState,
|
|
DetectionResult& result,
|
|
ParkingGuideAlgorithmControl& control);
|
|
|
|
int RecognizeModel2D(const QImage& frame,
|
|
const QByteArray& recognitionContext,
|
|
ModelRecognitionResult& result);
|
|
|
|
int DetectPersonInRegion2D(const QImage& frame,
|
|
const VrPersonDetectionParam& personParam,
|
|
PersonDetectionResult& result);
|
|
|
|
private:
|
|
std::unique_ptr<AapgsModelClassifier> m_modelClassifier;
|
|
std::unique_ptr<PersionModelDetector> m_personDetector;
|
|
};
|
|
|
|
struct PersonDetectionResult
|
|
{
|
|
QRectF roi;
|
|
QVector<QRectF> personBoxes;
|
|
int personCount = 0;
|
|
double confidence = 0.0;
|
|
bool personInRegion = false;
|
|
QString message;
|
|
};
|
|
|
|
#endif // PARKINGSPACEGUIDE_DETECTPRESENTER_H
|