From 5c8762f1f209e2781184a7816bbd3b6af78c0188 Mon Sep 17 00:00:00 2001
From: 李良庭 <liliangting@shlanbao.cn>
Date: 星期二, 22 四月 2025 15:33:45 +0800
Subject: [PATCH] no message

---
 cloud_viewer.cpp |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/cloud_viewer.cpp b/cloud_viewer.cpp
new file mode 100644
index 0000000..6303654
--- /dev/null
+++ b/cloud_viewer.cpp
@@ -0,0 +1,50 @@
+锘�#define PCL_SILENCE_MALLOC_WARNING 1
+#include <pcl/visualization/cloud_viewer.h>
+#include <pcl/point_types.h>
+#include <pcl/io/pcd_io.h>
+#include <atomic>
+#include <thread>
+
+std::atomic<int> user_data(0);
+
+void viewerOneOff(pcl::visualization::PCLVisualizer& viewer) {
+    viewer.setBackgroundColor(0.1, 0.1, 0.1);  // 娣辩伆鑳屾櫙鏇存槗瑙傚療
+    viewer.addCoordinateSystem(1.0);           // 娣诲姞鍧愭爣绯�
+    viewer.initCameraParameters();             // 鍒濆鍖栫浉鏈哄弬鏁�
+    std::cout << "Initial setup complete." << std::endl;
+}
+
+void viewerPsycho(pcl::visualization::PCLVisualizer& viewer) {
+    static unsigned count = 0;
+    viewer.removeShape("text");
+    viewer.addText("Frame: " + std::to_string(count++), 20, 30, 20, 1, 1, 1, "text");
+    user_data.fetch_add(1, std::memory_order_relaxed);
+}
+
+int main() {
+    // 鍔犺浇鐐逛簯锛堝甫閿欒澶勭悊锛�
+    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
+    if (pcl::io::loadPCDFile<pcl::PointXYZRGBA>("sampledata.pcd", *cloud) == -1) {
+        std::cerr << "Error: Failed to load PCD file!" << std::endl;
+        return -1;
+    }
+
+    // 鍒涘缓鍙鍖栧櫒
+    pcl::visualization::CloudViewer viewer("Enhanced Cloud Viewer");
+
+    // 鏄剧ず鐐逛簯
+    viewer.showCloud(cloud);
+
+    // 璁剧疆鍥炶皟鍑芥暟
+    viewer.runOnVisualizationThreadOnce(viewerOneOff);
+    viewer.runOnVisualizationThread(viewerPsycho);
+
+    // 涓诲惊鐜�
+    while (!viewer.wasStopped()) {
+        // 绀轰緥澶勭悊閫昏緫锛堢嚎绋嬪畨鍏級
+        user_data.fetch_add(1, std::memory_order_relaxed);
+        std::this_thread::sleep_for(std::chrono::milliseconds(50));
+    }
+
+    return 0;
+}
\ No newline at end of file

--
Gitblit v1.9.3