/
klischa
/
AstraScanner2
Обзор
Документация
Войти
/
klischa
/
AstraScanner2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/controllers/ScanWorkflow.h
158 строк
5 KB
k k
fix: viewer display, cloud counter, RGB preview, timer initialization
15 июл 2026, 12:58
15 июл 2026, 12:58
cb20a77
Код
Авторство
О чём код?
#ifndef SCANWORKFLOW_H #define SCANWORKFLOW_H #include <QObject> #include <QElapsedTimer> #include <QMutex> #include <QSharedPointer> #include <atomic> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <Eigen/Geometry> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include "../tracking/SurfelCoverageTracker.h" namespace cv { class Mat; } class CaptureSessionController; class ProjectManager; class ViewerCoordinator; class QTimer; class QLabel; class QPushButton; class QTextEdit; class QVTKOpenGLNativeWidget; class ScanWorkflow : public QObject { Q_OBJECT public: struct Widgets { QPushButton *previewBtn = nullptr; QPushButton *scanBtn = nullptr; QPushButton *pauseBtn = nullptr; QPushButton *stopBtn = nullptr; QPushButton *clearBtn = nullptr; QLabel *rgbLabel = nullptr; QLabel *depthLabel = nullptr; QLabel *scannerPoseLabel = nullptr; QLabel *trackingQualityLabel = nullptr; QLabel *alignmentQualityLabel = nullptr; QLabel *depthQualityLabel = nullptr; QLabel *driftQualityLabel = nullptr; QLabel *coverageSummaryLabel = nullptr; QLabel *elapsedTimeLabel = nullptr; QLabel *frameCountLabel = nullptr; QLabel *fpsLabel = nullptr; QVTKOpenGLNativeWidget *vtkWidget = nullptr; QTextEdit *logTextEdit = nullptr; QTimer *viewerUpdateTimer = nullptr; QTimer *scanTimeoutTimer = nullptr; QLabel *calibRgbLabel = nullptr; QLabel *homeCalibRgbLabel = nullptr; }; explicit ScanWorkflow(CaptureSessionController *captureSession, ProjectManager *project, ViewerCoordinator *viewer, QObject *parent = nullptr); ~ScanWorkflow() override; void bindWidgets(const Widgets &w); // Scan control void onPreviewClicked(); void onScanClicked(); void onPauseClicked(); void onStopClicked(); void onClearClicked(); void checkScanTimeout(); // Frame handlers void onNewFrame(QSharedPointer<cv::Mat> color, QSharedPointer<cv::Mat> depth); void onPointCloudReady(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud); void onFrameProcessed(int totalFrames); void onCaptureWarning(const QString &msg); void onCaptureError(const QString &msg); void onMarkersDetected(QSharedPointer<cv::Mat> markersImage); // State bool isScanning() const { return m_scanning; } bool isCapturing() const; const pcl::PointCloud<pcl::PointXYZRGB>::Ptr& accumulatedCloud() const { return m_accumulatedCloud; } void clearAccumulatedCloud(); void updateScanQualityPanel(const QString &trackingText, int trackingLevel, const QString &alignmentText, int alignmentLevel, const QString &depthText, int depthLevel, const QString &driftText, int driftLevel); void updateViewer(); // Turntable integration void onTurntableToggled(bool enabled); void onTurntableTick(); void setTurntableStatusText(const QString &text); void stopTurntableMode(bool uncheckCheckbox); signals: void scanStarted(); void scanStopped(); void cloudReady(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud); void captureError(const QString &msg); void cloudSizeChanged(int size); private: void startCapture(bool enableCloudProcessing); bool stopCapture(); void setCaptureButtonsState(bool preview, bool scan, bool pause, bool stop); void resetCaptureStats(); void resetScanQualityPanel(); void updateCoverageSummary(); void accumulateIncomingCloud(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud); void showLivePreviewCloud(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud); void resetConfidenceCoverage(); void accumulateConfidenceCoverage(const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud); pcl::PointCloud<pcl::PointXYZRGB>::Ptr buildQualityHeatmapCloud( const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud); void updateScannerPoseLabel(const Eigen::Affine3f &pose, bool showEuler); void updateFrameStats(int totalFrames); void updateElapsedTimeLabel(); void updateRgbPreviewFrame(const cv::Mat &color, bool updateGui); void updateDepthPreviewFrame(const cv::Mat &depth, bool updateGui); void autoSaveAccumulatedCloudToProject(); void appendLog(const QString &text); CaptureSessionController *m_captureSession = nullptr; ProjectManager *m_project = nullptr; ViewerCoordinator *m_viewerCoordinator = nullptr; Widgets m_w; // Scan state bool m_scanning = false; bool m_cloudProcessing = false; int m_frameSkip = 3; int m_frameCounter = 0; int m_totalFrames = 0; QElapsedTimer m_scanTimer; // Cloud accumulation pcl::PointCloud<pcl::PointXYZRGB>::Ptr m_accumulatedCloud; std::atomic<bool> m_viewerBusy{false}; QMutex m_cloudMutex; // Quality std::unique_ptr<SurfelCoverageTracker> m_surfelCoverageTracker; int m_lastTrackingQualityLevel = 1; int m_lastAlignmentQualityLevel = 1; int m_lastDepthQualityLevel = 1; int m_lastDriftQualityLevel = 1; // Preview cv::Mat m_lastColorFrame; int m_depthColormap = cv::COLORMAP_JET; enum ScanQualityLevel { QualityGood = 0, QualityWarning = 1, QualityPoor = 2 }; }; #endif // SCANWORKFLOW_H