Преглед изворни кода

1、添加识别结果越界判断;
2、cmake文件添加cuda库查找判断;

LiuZe пре 11 месеци
родитељ
комит
2133d771e1
2 измењених фајлова са 15 додато и 3 уклоњено
  1. 8 2
      CMakeLists.txt
  2. 7 1
      detect/detect_manager.cpp

+ 8 - 2
CMakeLists.txt

@@ -3,7 +3,13 @@ set(SON_PROJECT_NAME tof3d)
 message("========== Load son project ${SON_PROJECT_NAME} ==========" )
 
 unset(OPTION_ENABLE_TENSORRT_DETECT_CODE CACHE)
-option(OPTION_ENABLE_TENSORRT_DETECT_CODE "" OFF)
+
+find_package(CUDA REQUIRED)
+if (${CUDA_FOUND})
+    option(OPTION_ENABLE_TENSORRT_DETECT_CODE "" ON)
+else ()
+    option(OPTION_ENABLE_TENSORRT_DETECT_CODE "" OFF)
+endif ()
 message("<=${SON_PROJECT_NAME}=> OPTION_ENABLE_TENSORRT_DETECT_CODE: " ${OPTION_ENABLE_TENSORRT_DETECT_CODE})
 
 if (OPTION_ENABLE_TENSORRT_DETECT_CODE)
@@ -53,7 +59,7 @@ if (OPTION_ENABLE_TENSORRT_DETECT_CODE)
             ${TensorRT_LIBRARIES}
     )
 
-    aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/detect yolov8_detect)
+    aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/detect/tensorrt_detect yolov8_detect)
 else ()
     aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/detect/onnx_detect yolov8_detect)
 endif ()

+ 7 - 1
detect/detect_manager.cpp

@@ -68,7 +68,13 @@ void DetectManager::run() {
             // 标记识别点云
             for (auto &obj: objs) {
                 auto seg_points = detector->getPointsFromObj(obj);
-                int device_index = (int(seg_points[0].x / 640) * 0x01) | (int(seg_points[0].y / 480) << 1);
+                int device_index = (int(obj.rect.x / 640) * 0x01) | (int(obj.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);
+                if (device_index != device_index_check) {
+                    // TODO:存图
+                    continue;
+                }
                 detect_result.wheel[device_index].confidence = obj.prob;
 
                 if (obj.prob > 0.9) {