#ifndef POINTCLOUDPROCESSOR_H #define POINTCLOUDPROCESSOR_H #include #include #include #include #include #include #include class PointCloudProcessor : public QObject { Q_OBJECT public: explicit PointCloudProcessor(QObject *parent = nullptr); ~PointCloudProcessor(); bool initializeOpenCL(); void setCameraIntrinsics(float fx, float fy, float cx, float cy); void setZScaleFactor(float scale); void processDepthData(const QByteArray &depthData, uint32_t blockId); void processPointCloudData(const QByteArray &cloudData, uint32_t blockId); void setDenoiseEnabled(bool enabled); void setDenoiseNeighborSupport(int minNeighbors); void setDenoiseLowTailPermille(int permille); void setDenoiseDepthBandPermille(int permille); signals: void pointCloudReady(pcl::PointCloud::Ptr cloud, uint32_t blockId); void errorOccurred(const QString &error); private: pcl::PointCloud::Ptr applyDenoise(const pcl::PointCloud::Ptr &input); void loadLowerCalibration(); void cleanupOpenCL(); float m_fx; float m_fy; float m_cx; float m_cy; float m_zScale; int m_imageWidth; int m_imageHeight; int m_totalPoints; cl_platform_id m_platform; cl_device_id m_device; cl_context m_context; cl_command_queue m_queue; cl_program m_program; cl_kernel m_kernel; cl_mem m_depthBuffer; cl_mem m_xyzBuffer; bool m_clInitialized; std::atomic_bool m_denoiseEnabled; float m_voxelLeafSize; std::atomic_int m_denoiseNeighborSupport; std::atomic_int m_denoiseLowTailPermille; std::atomic_int m_denoiseDepthBandPermille; // Calibration params aligned with lower-machine model float m_k1; float m_k2; float m_p1; float m_p2; float m_p5; float m_p6; float m_p7; float m_p8; bool m_hasLowerCalibration; // Temporal stabilizers for denoise to reduce frame-to-frame flicker. std::mutex m_denoiseStateMutex; bool m_hasAnchorMeanZ; float m_anchorMeanZFiltered; bool m_hasLowCutZ; float m_lowCutZFiltered; }; #endif // POINTCLOUDPROCESSOR_H