Browse Source

change detetion_lidar_centerpoint.

yuchuli 2 years ago
parent
commit
4b40f88ee5

+ 17 - 3
src/detection/detection_lidar_centerpoint/detection_lidar_centerpoint.pro

@@ -22,7 +22,9 @@ SOURCES += \
         lib/preprocess/voxel_generator.cpp \
         lib/utils.cpp \
         main.cpp \
-        tensorrt_common/tensorrt_common.cpp
+        tensorrt_common/tensorrt_common.cpp  \
+    ../../include/msgtype/object.pb.cc \
+    ../../include/msgtype/objectarray.pb.cc
 
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
@@ -59,6 +61,16 @@ INCLUDEPATH +=$$PWD/perception_utils/include
 
 LIBS += -lrt -ldl -lnvinfer -lcudnn  -lcudart -lnvparsers -lnvonnxparser -lnvinfer_plugin -lstdc++fs
 
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+INCLUDEPATH += $$PWD/../../include/msgtype
+
 
 CUDA_SOURCES += \
     lib/network/scatter_kernel.cu \
@@ -79,7 +91,7 @@ SYSTEM_NAME = linux         # 自己系统环境 'Win32', 'x64', or 'Win64'
 
 SYSTEM_TYPE = 64           #操作系统位数 '32' or '64',
 
-CUDA_ARCH = sm_72          # cuda架构, for example 'compute_10', 'compute_11', 'sm_10'
+CUDA_ARCH = sm_72 # xavier sm_72          # cuda架构, for example 'compute_10', 'compute_11', 'sm_10'
 
 NVCC_OPTIONS = --use_fast_math --compiler-options "-fPIC"
 
@@ -157,5 +169,7 @@ HEADERS += \
     include/lidar_centerpoint/postprocess/postprocess_kernel.hpp \
     include/lidar_centerpoint/preprocess/pointcloud_densification.hpp \
     include/lidar_centerpoint/preprocess/preprocess_kernel.hpp \
-    include/lidar_centerpoint/preprocess/voxel_generator.hpp
+    include/lidar_centerpoint/preprocess/voxel_generator.hpp \
+    ../../include/msgtype/object.pb.h \
+    ../../include/msgtype/objectarray.pb.h
 

+ 13 - 4
src/detection/detection_lidar_centerpoint/include/lidar_centerpoint/centerpoint_config.hpp

@@ -81,12 +81,21 @@ public:
   std::size_t point_feature_size_{4};    // x, y, z and time-lag
   std::size_t max_point_in_voxel_size_{32};
   std::size_t max_voxel_size_{40000};
-  float range_min_x_{-89.6f};
-  float range_min_y_{-89.6f};
+//  float range_min_x_{-89.6f};
+//  float range_min_y_{-89.6f};
+//  float range_min_z_{-3.0f};
+//  float range_max_x_{89.6f};
+//  float range_max_y_{89.6f};
+//  float range_max_z_{5.0f};
+
+  float range_min_x_{-40.0f};
+  float range_min_y_{-40.0f};
   float range_min_z_{-3.0f};
-  float range_max_x_{89.6f};
-  float range_max_y_{89.6f};
+  float range_max_x_{40.0f};
+  float range_max_y_{40.0f};
   float range_max_z_{5.0f};
+
+
   float voxel_size_x_{0.32f};
   float voxel_size_y_{0.32f};
   float voxel_size_z_{8.0f};

+ 5 - 0
src/detection/detection_lidar_centerpoint/lib/centerpoint_trt.cpp

@@ -103,6 +103,8 @@ bool CenterPointTRT::detect(
   const pcl::PointCloud<pcl::PointXYZI>::Ptr & pc_ptr,
   std::vector<Box3D> & det_boxes3d)
 {
+
+    int64_t time1 = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
     std::fill(voxels_.begin(), voxels_.end(), 0);
     std::fill(coordinates_.begin(), coordinates_.end(), -1);
     std::fill(num_points_per_voxel_.begin(), num_points_per_voxel_.end(), 0);
@@ -119,6 +121,9 @@ bool CenterPointTRT::detect(
     }
 
     inference();
+    int64_t time2 = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
+
+    std::cout<<" infer use: "<<(time2-time1)<<std::endl;
 
     postProcess(det_boxes3d);
 

+ 67 - 0
src/detection/detection_lidar_centerpoint/main.cpp

@@ -6,6 +6,12 @@
 #include <lidar_centerpoint/centerpoint_trt.hpp>
 #include <lidar_centerpoint/preprocess/pointcloud_densification.hpp>
 
+
+#include "modulecomm.h"
+
+void * gpa;
+void * gpdetect;
+
 using namespace centerpoint;
 
 std::unique_ptr<CenterPointTRT> detector_ptr_{nullptr};
@@ -50,10 +56,71 @@ void init()
 
 }
 
+void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    if(nSize <=16)return;
+    unsigned int * pHeadSize = (unsigned int *)strdata;
+    if(*pHeadSize > nSize)
+    {
+        std::cout<<"ListenPointCloud data is small headsize ="<<*pHeadSize<<"  data size is"<<nSize<<std::endl;
+    }
+
+    QTime xTime;
+    xTime.start();
+
+    pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(
+                new pcl::PointCloud<pcl::PointXYZI>());
+    int nNameSize;
+    nNameSize = *pHeadSize - 4-4-8;
+    char * strName = new char[nNameSize+1];strName[nNameSize] = 0;
+    memcpy(strName,(char *)((char *)strdata +4),nNameSize);
+    point_cloud->header.frame_id = strName;
+    memcpy(&point_cloud->header.seq,(char *)strdata+4+nNameSize,4);
+    memcpy(&point_cloud->header.stamp,(char *)strdata+4+nNameSize+4,8);
+    int nPCount = (nSize - *pHeadSize)/sizeof(pcl::PointXYZI);
+    int i;
+    pcl::PointXYZI * p;
+    p = (pcl::PointXYZI *)((char *)strdata + *pHeadSize);
+    for(i=0;i<nPCount;i++)
+    {
+        pcl::PointXYZI xp;
+//        if((p->x<-30)||(p->x>30)||(p->y>50)||(p->y<-50))
+//        {
+
+//        }
+//        else
+//        {
+            memcpy(&xp,p,sizeof(pcl::PointXYZI));
+            xp.z = xp.z;
+            point_cloud->push_back(xp);
+
+//        }
+        p++;
+//        xp.x = p->x;
+//        xp.y = p->y;
+//        xp.z = p->z;
+//        xp.intensity = p->intensity;
+//        point_cloud->push_back(xp);
+//        p++;
+    }
+
+//    std::cout<<"pcl time is "<<xTime.elapsed()<<std::endl;
+
+
+    std::vector<Box3D> det_boxes3d;
+    detector_ptr_ ->detect(point_cloud,det_boxes3d);
+    std::cout<<" box size: "<<det_boxes3d.size()<<std::endl;
+
+
+}
+
+
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
     init();
 
+    gpa = iv::modulecomm::RegisterRecv("lidarpc_center",ListenPointCloud);
+
     return a.exec();
 }