Browse Source

1、更新;

LiuZe 11 months ago
parent
commit
c7a56592ce
4 changed files with 133 additions and 15 deletions
  1. 5 5
      CMakeLists.txt
  2. 114 0
      README.md
  3. 12 8
      detect/detect_manager.cpp
  4. 2 2
      vzense/device_tof3d.cpp

+ 5 - 5
CMakeLists.txt

@@ -4,12 +4,12 @@ message("========== Load son project ${SON_PROJECT_NAME} ==========" )
 
 unset(OPTION_ENABLE_TENSORRT_DETECT_CODE CACHE)
 
-find_package(CUDA REQUIRED)
-if (${CUDA_FOUND})
-    option(OPTION_ENABLE_TENSORRT_DETECT_CODE "" ON)
-else ()
+#find_package(CUDA REQUIRED)
+#if (${CUDA_FOUND})
+#    option(OPTION_ENABLE_TENSORRT_DETECT_CODE "" ON)
+#else ()
     option(OPTION_ENABLE_TENSORRT_DETECT_CODE "" OFF)
-endif ()
+#endif ()
 message("<=${SON_PROJECT_NAME}=> OPTION_ENABLE_TENSORRT_DETECT_CODE: " ${OPTION_ENABLE_TENSORRT_DETECT_CODE})
 
 if (OPTION_ENABLE_TENSORRT_DETECT_CODE)

+ 114 - 0
README.md

@@ -1,2 +1,116 @@
 # Vzense-Tof-3D
 
+## 一、环境搭建
+
+### 1、工具准备
+
+```shell
+sudo apt install gcc g++ vim curl git
+```
+
+
+### 2、第三方库安装
+#### 2.2 cmake
+
+```shell
+# 方案一 官网源码安装
+curl https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0.tar.gz
+# 方案二 公司源码
+git clone http://47.108.171.148:10080/LiuZe/env-vzense-tof.git
+# 开始编译安装
+tar -xvf cmake-3.28.0.tar.gz
+cd cmake-3.28.0
+./bootstrap
+make -jn
+sudo make install
+```
+
+#### 2.3 grpc、protobuf
+
+```shell
+# 方案一 官网源码安装
+git clone http://47.108.171.148:10080/LiuZe/env-vzense-tof.git
+cd grpc
+git submit init
+git submit update
+# 方案二 公司源码安装
+git clone http://47.108.171.148:10080/LiuZe/env-vzense-tof.git
+# 开始编译安装
+mkdir build
+cd build
+make -jn
+
+```
+
+#### 2.4 ceres
+
+```shell
+# 方案二 公司源码安装
+git clone http://47.108.171.148:10080/LiuZe/env-vzense-tof.git
+tar -xvf ceres.tar.gz
+tar -xvf g-test-flags-log.tar.gz
+
+# gtest
+cd google-test
+mkdir build
+cd build
+cmake ..
+# gflag
+cd gflags
+mkdir build
+cd build
+cmake ..
+# glog
+cd glog
+mkdir build
+cd build
+cmake -DBUILD_SHARED_LIBS=OFF ..
+# ceres
+cmake ..
+```
+
+#### 2.5 rabbitmq-c
+
+```shell
+# 方案二 公司源码安装
+git clone http://47.108.171.148:10080/LiuZe/env-vzense-tof.git
+
+mkdir build
+cd build
+cmake ..
+make -jn
+sudo make install
+```
+
+#### 2.5 pcl
+
+```shell
+sudo apt install libpcl-dev
+```
+
+
+
+### 3、代码拷贝
+
+```shell
+sudo apt install git librabbitmq-dev
+git clone http://47.108.171.148:10080/LiuZe/PublicProjectLibrary.git
+cd PublicProjectLibrary
+git submit init
+git submit update	# etc克隆会比较慢
+cd etc
+git check -b origin/branch	# branch 分支名
+cd ../project/Vzense-Tof-3D
+git check -b origin/branch	# branch 分支名
+```
+
+### 4、jetson orin nano 配置
+
+```shell
+sudo apt update
+sudo apt install nvidia-jetpack
+
+# 修改cmakelist project/Vzense_tof_3D目录下CmakeList.txt
+# 修改 OPTION_ENABLE_TENSORRT_DETECT_CODE 为 ON
+```
+

+ 12 - 8
detect/detect_manager.cpp

@@ -74,27 +74,31 @@ void DetectManager::run() {
             DLOG(INFO) << "cost time is " << cost.count() * 1000 << " ms";
 
             // 标记识别点云
-            for (auto &obj: objs) {
-                auto seg_points = detector->getPointsFromObj(obj);
-                int device_index = (int(obj.rect.x / 640) * 0x01) | (int(obj.rect.y / 480) << 1);
+            for (auto iter = objs.begin(); iter != objs.end(); iter++) {
+                auto seg_points = detector->getPointsFromObj(*iter);
+                int device_index = (int(iter->rect.x / 640) * 0x01) | (int(iter->rect.y / 480) << 1);
                 // 校验识别矩形框是否越界
-                int device_index_check = (int((obj.rect.x + obj.rect.width) / 640) * 0x01) | (int((obj.rect.y + obj.rect.height) / 480) << 1);
+                int device_index_check = (int((iter->rect.x + iter->rect.width) / 640) * 0x01) | (int((iter->rect.y + iter->rect.height) / 480) << 1);
                 if (device_index != device_index_check) {
                     // TODO:存图
+                    LOG(INFO) << "device_index_check " << device_index_check << " != device_index " << device_index;
+                    LOG(INFO) << "obj.rect.x: " << iter->rect.x << ", iter->rect.y: " << iter->rect.x << ", obj.rect.width: " << iter->rect.width << ", obj.rect.height: " << iter->rect.height;
+                    objs.erase(iter);
+                    iter--;
                     continue;
                 }
-                detect_result.wheel[device_index].confidence = obj.prob;
+                detect_result.wheel[device_index].confidence = iter->prob;
 
-                if (obj.prob > 0.9) {
+                if (iter->prob > 0.9) {
                     detect_result.wheel[device_index].detectOk = true;
-                    float d = MAX(obj.rect.height, obj.rect.width) / 2;
+                    float d = MAX(iter->rect.height, iter->rect.width) / 2;
                     pcl::PointXYZ point;
                     int x_alpha = (device_index & 0x1);
                     int y_alpha = ((device_index & 0x2) >> 1);
                     for (auto &pt: seg_points) {    // use 7.5~9ms
                         pt.x -= x_alpha * t_device_mat[device_index].irMat.cols;
                         pt.y -= y_alpha * t_device_mat[device_index].irMat.rows;
-                        t_device_mat[device_index].pointMat.at<cv::Vec4f>(pt)[3] = obj.prob;
+                        t_device_mat[device_index].pointMat.at<cv::Vec4f>(pt)[3] = iter->prob;
                         point.x = t_device_mat[device_index].pointMat.at<cv::Vec4f>(pt)[0];
                         point.y = t_device_mat[device_index].pointMat.at<cv::Vec4f>(pt)[1];
                         point.z = t_device_mat[device_index].pointMat.at<cv::Vec4f>(pt)[2];

+ 2 - 2
vzense/device_tof3d.cpp

@@ -497,6 +497,8 @@ void DeviceTof3D::run(const DeviceAzimuth &azimuth) {
 
     cv::Mat t_ir_img;
     cv::Mat t_point_img;
+    VzFrame depthFrame = {0};
+    VzFrame irFrame = {0};
     VzVector3f *worldV = new VzVector3f[480 * 640];
 
     auto t_start_time = std::chrono::steady_clock::now();
@@ -513,8 +515,6 @@ void DeviceTof3D::run(const DeviceAzimuth &azimuth) {
         if (device.condit->is_alive()) {
             Error_manager ret;
             DeviceTof3DSaveInfo depthInfo;
-            VzFrame depthFrame = {0};
-            VzFrame irFrame = {0};
             Error_manager vz_ret = {FAILED, NORMAL};
 
             device.handle_mutex->lock();