Переглянути джерело

change detection_lidar_transfusion, chang voxel, but not test ok.need some work.

yuchuli 5 днів тому
батько
коміт
73c0a2225e

+ 1 - 1
src/detection/detection_lidar_transfusion/detection_lidar_transfusion.pro

@@ -1,6 +1,6 @@
 QT -= gui
 
-CONFIG += c++1z console
+CONFIG += c++1z #console
 CONFIG -= app_bundle
 
 # You can make your code fail to compile if it uses deprecated APIs.

+ 38 - 1
src/detection/detection_lidar_transfusion/main.cpp

@@ -5,6 +5,41 @@
 transfusion_call * gptf;
 
 #include <pcl/io/pcd_io.h>
+
+#include <QFile>
+
+
+void LoadBin(pcl::PointCloud<pcl::PointXYZI>::Ptr & point_cloud,std::string strpath)
+{
+    pcl::PointXYZI xp;
+
+    point_cloud->height = 1;
+
+    QFile xFile;
+    xFile.setFileName(strpath.data());
+    if(xFile.open(QIODevice::ReadOnly))
+    {
+        while(1)
+        {
+        float x,y,z,i,ring;
+        int nread;
+//        std::cout<<"float size : "<<sizeof(float)<<std::endl;
+        nread = xFile.read((char *)&x,sizeof(float));
+        if(nread < 1)break;
+        xFile.read((char *)&y,sizeof(float));
+        xFile.read((char *)&z,sizeof(float));
+        xFile.read((char *)&i,sizeof(float));
+ //       xFile.read((char *)&ring,sizeof(float));
+ //       std::cout<<x<<" "<<y<<" "<<z<<" "<<i<<std::endl;
+        xp.x = x; xp.y = y; xp.z = z; xp.intensity = i*256;
+        std::cout<<" x: "<<xp.x<<" y:"<<xp.y<<" z:"<<xp.z<<" int:"<<xp.intensity<<" ring:"<<ring<<std::endl;
+        point_cloud->points.push_back(xp);++point_cloud->width;
+        }
+    }
+    xFile.close();
+
+}
+
 void testdet(std::string & path)
 {
     pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(
@@ -12,6 +47,8 @@ void testdet(std::string & path)
 
     pcl::io::loadPCDFile<pcl::PointXYZI>(path,*point_cloud);
 
+ //   LoadBin(point_cloud, path);
+
     std::vector<Box3D> det_boxes3d;
     int i;
     for(i=0;i<10;i++)
@@ -28,7 +65,7 @@ int main(int argc, char *argv[])
 
     gptf = new transfusion_call();
 
-    std::string strpath = "/home/nvidia/1.pcd";
+    std::string strpath = "/home/nvidia/1.pcd"; //"/home/nvidia/data/tem/000005.bin";//
     testdet(strpath);
 
     return a.exec();

+ 30 - 2
src/detection/detection_lidar_transfusion/preprocess/pointcloud_densification.cpp

@@ -98,14 +98,42 @@ bool PointCloudDensification::enqueuePointCloud(
 //}
 
 
+
 void PointCloudDensification::enqueue(const pcl::PointCloud<pcl::PointXYZI>::Ptr & pc_ptr)
 {
+    int npsize = pc_ptr->width * pc_ptr->height;
+    int nsize = npsize * 13;
+
+    std::cout<<"width: "<<pc_ptr->width<<" height: "<<pc_ptr->height<<std::endl;
+
+    char * pdata = new char[nsize];
+
+    int i;
+    for(i=0;i<npsize;i++)
+    {
+        float x,y,z;
+        unsigned char nintensity;
+        pcl::PointXYZI point = pc_ptr->at(i);
+        x = point.x;  y = point.y; z = point.z; nintensity = point.intensity;
+        memcpy(pdata+i*13+0,&x,4);memcpy(pdata+i*13+4,&y,4);memcpy(pdata+i*13+8,&z,4);memcpy(pdata+i*13+12,&nintensity,1);
+    }
+
+
+//    auto data_d = cuda::make_unique<uint8_t[]>(
+//      sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * sizeof(pcl::PointXYZI) / sizeof(uint8_t));
+
     auto data_d = cuda::make_unique<uint8_t[]>(
-      sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * sizeof(pcl::PointXYZI) / sizeof(uint8_t));
+      sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * 13 / sizeof(uint8_t));
 
     CHECK_CUDA_ERROR(cudaMemcpyAsync(
-      data_d.get(), pc_ptr->points.data(), sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * sizeof(pcl::PointXYZI),
+      data_d.get(), pdata, sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * 13,
       cudaMemcpyHostToDevice, stream_));
+
+    delete pdata;
+
+//    CHECK_CUDA_ERROR(cudaMemcpyAsync(
+//      data_d.get(), pc_ptr->points.data(), sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * sizeof(pcl::PointXYZI),
+//      cudaMemcpyHostToDevice, stream_));
 //    CHECK_CUDA_ERROR(cudaMemcpyAsync(
 //      data_d.get(), pc_ptr->data(), sizeof(uint8_t) * pc_ptr->width * pc_ptr->height * sizeof(pcl::PointXYZI),
 //      cudaMemcpyHostToDevice, stream_));

+ 5 - 1
src/detection/detection_lidar_transfusion/preprocess/voxel_generator.cpp

@@ -81,10 +81,14 @@ std::size_t VoxelGenerator::generateSweepPoints(
         cudaMemcpyHostToDevice, stream_));
       CHECK_CUDA_ERROR(cudaStreamSynchronize(stream_));
 
+ //     std::cout<<" size x: "<<sizeof(pcl::PointXYZI)<<std::endl;
       pre_ptr_->generateSweepPoints_launch(
-        pc_cache_iter->data_d.get(), sweep_num_points, sizeof(pcl::PointXYZI), time_lag,
+        pc_cache_iter->data_d.get(), sweep_num_points, 13, time_lag,
         affine_past2current_d_.get(), points_d.get() + shift);
 //      pre_ptr_->generateSweepPoints_launch(
+//        pc_cache_iter->data_d.get(), sweep_num_points, sizeof(pcl::PointXYZI), time_lag,
+//        affine_past2current_d_.get(), points_d.get() + shift);
+//      pre_ptr_->generateSweepPoints_launch(
 //        pc_cache_iter->data_d.get(), sweep_num_points, cloud_info_.point_step, time_lag,
 //        affine_past2current_d_.get(), points_d.get() + shift);
       point_counter += sweep_num_points;

+ 3 - 3
src/detection/detection_lidar_transfusion/transfusion_call.cpp

@@ -20,9 +20,9 @@ transfusion_call::transfusion_call()
     float score_threshold = 0.2;
 
     voxels_num.push_back(5000);voxels_num.push_back(30000);voxels_num.push_back(60000);
-    point_cloud_range.push_back(-76.8);point_cloud_range.push_back(-76.8);point_cloud_range.push_back(-3.0);
-    point_cloud_range.push_back(76.8);point_cloud_range.push_back(76.8);point_cloud_range.push_back(5.0);
-    voxel_size.push_back(0.3);voxel_size.push_back(0.3);voxel_size.push_back(8.0);
+    point_cloud_range.push_back(-92.16);point_cloud_range.push_back(-92.16);point_cloud_range.push_back(-3.0);
+    point_cloud_range.push_back(92.16);point_cloud_range.push_back(92.16);point_cloud_range.push_back(7.0);
+    voxel_size.push_back(0.24);voxel_size.push_back(0.24);voxel_size.push_back(10.0);
     yaw_norm_thresholds.push_back(0.3);yaw_norm_thresholds.push_back(0.3);yaw_norm_thresholds.push_back(0.3);
     yaw_norm_thresholds.push_back(0.3);yaw_norm_thresholds.push_back(0.0);