|
@@ -14,7 +14,7 @@
|
|
* limitations under the License.
|
|
* limitations under the License.
|
|
*/
|
|
*/
|
|
|
|
|
|
-// close lidar_ufk_pda
|
|
|
|
|
|
+#include <QCoreApplication>
|
|
#include "argsParser.h"
|
|
#include "argsParser.h"
|
|
#include "buffers.h"
|
|
#include "buffers.h"
|
|
#include "common.h"
|
|
#include "common.h"
|
|
@@ -48,8 +48,11 @@
|
|
#include <thread>
|
|
#include <thread>
|
|
#include "objectarray.pb.h"
|
|
#include "objectarray.pb.h"
|
|
|
|
|
|
|
|
+#define M_PI 3.14159265358979323846
|
|
|
|
+
|
|
const std::string gSampleName = "TensorRT.sample_onnx_centerpoint";
|
|
const std::string gSampleName = "TensorRT.sample_onnx_centerpoint";
|
|
|
|
|
|
|
|
+float threshold = 0.5;
|
|
|
|
|
|
CenterPoint * centerpoint = nullptr ;
|
|
CenterPoint * centerpoint = nullptr ;
|
|
|
|
|
|
@@ -63,26 +66,24 @@ void * gpa;
|
|
void * gpdetect;
|
|
void * gpdetect;
|
|
|
|
|
|
|
|
|
|
-string lidarname = "lidar_pointpillar";
|
|
|
|
-//string lidarname = "lidar_pc";
|
|
|
|
|
|
+string lidarname = "lidar_pc";
|
|
string detectname = "lidar_track";
|
|
string detectname = "lidar_track";
|
|
|
|
|
|
|
|
+
|
|
|
|
+//change lidarpoints to waymo type,x-->forward,y-->left
|
|
void PclXYZITToArray(
|
|
void PclXYZITToArray(
|
|
const pcl::PointCloud<pcl::PointXYZI>::Ptr& in_pcl_pc_ptr,
|
|
const pcl::PointCloud<pcl::PointXYZI>::Ptr& in_pcl_pc_ptr,
|
|
float* out_points_array, const float normalizing_factor) {
|
|
float* out_points_array, const float normalizing_factor) {
|
|
for (size_t i = 0; i < in_pcl_pc_ptr->size(); ++i) {
|
|
for (size_t i = 0; i < in_pcl_pc_ptr->size(); ++i) {
|
|
pcl::PointXYZI point = in_pcl_pc_ptr->at(i);
|
|
pcl::PointXYZI point = in_pcl_pc_ptr->at(i);
|
|
- out_points_array[i * 5 + 0] = point.x;
|
|
|
|
- out_points_array[i * 5 + 1] = point.y;
|
|
|
|
|
|
+ out_points_array[i * 5 + 0] = point.y;
|
|
|
|
+ out_points_array[i * 5 + 1] = -point.x;
|
|
out_points_array[i * 5 + 2] = point.z;
|
|
out_points_array[i * 5 + 2] = point.z;
|
|
out_points_array[i * 5 + 3] =
|
|
out_points_array[i * 5 + 3] =
|
|
static_cast<float>(point.intensity / normalizing_factor);
|
|
static_cast<float>(point.intensity / normalizing_factor);
|
|
out_points_array[i * 5 + 4] = 0;
|
|
out_points_array[i * 5 + 4] = 0;
|
|
|
|
|
|
-// std::cout<<"xyz="<<point.x<<point.y<<point.z<<std::endl;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- std::cout<<"the intensity = "<< out_points_array[i * 5 + 3]<< std::endl;
|
|
|
|
|
|
+ //std::cout<<"the intensity = "<< out_points_array[i * 5 + 3]<< std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -96,15 +97,20 @@ void GetLidarObj(std::vector<Box> &predResult,iv::lidar::objectarray & lidarobjv
|
|
|
|
|
|
Box result = predResult[idx];
|
|
Box result = predResult[idx];
|
|
|
|
|
|
- if (result.score < 0.2) continue;
|
|
|
|
|
|
+ if (result.score < threshold) continue;
|
|
|
|
|
|
std::cout<<" The scores = "<<result.score<<std::endl;
|
|
std::cout<<" The scores = "<<result.score<<std::endl;
|
|
|
|
|
|
- lidarobj.set_tyaw(result.theta);
|
|
|
|
|
|
+ lidarobj.set_tyaw(-result.theta);
|
|
|
|
+
|
|
|
|
+ std::cout<<" The theta = "<<result.theta<<std::endl;
|
|
|
|
+ std::cout<<" The xyz = "<<result.cls<<" "<<result.w<<" "<<result.l<<" "<<result.h<<std::endl;
|
|
|
|
+
|
|
|
|
+
|
|
iv::lidar::PointXYZ centroid;
|
|
iv::lidar::PointXYZ centroid;
|
|
iv::lidar::PointXYZ * _centroid;
|
|
iv::lidar::PointXYZ * _centroid;
|
|
- centroid.set_x(result.x);
|
|
|
|
- centroid.set_y(result.y);
|
|
|
|
|
|
+ centroid.set_x(-result.y);
|
|
|
|
+ centroid.set_y(result.x);
|
|
centroid.set_z(result.z);
|
|
centroid.set_z(result.z);
|
|
_centroid = lidarobj.mutable_centroid();
|
|
_centroid = lidarobj.mutable_centroid();
|
|
_centroid->CopyFrom(centroid);
|
|
_centroid->CopyFrom(centroid);
|
|
@@ -127,8 +133,8 @@ void GetLidarObj(std::vector<Box> &predResult,iv::lidar::objectarray & lidarobjv
|
|
|
|
|
|
iv::lidar::PointXYZ position;
|
|
iv::lidar::PointXYZ position;
|
|
iv::lidar::PointXYZ * _position;
|
|
iv::lidar::PointXYZ * _position;
|
|
- position.set_x(result.x);
|
|
|
|
- position.set_y(result.y);
|
|
|
|
|
|
+ position.set_x(-result.y);
|
|
|
|
+ position.set_y(result.x);
|
|
position.set_z(result.z);
|
|
position.set_z(result.z);
|
|
_position = lidarobj.mutable_position();
|
|
_position = lidarobj.mutable_position();
|
|
_position->CopyFrom(position);
|
|
_position->CopyFrom(position);
|
|
@@ -140,9 +146,11 @@ void GetLidarObj(std::vector<Box> &predResult,iv::lidar::objectarray & lidarobjv
|
|
|
|
|
|
iv::lidar::PointXYZI point_cloud;
|
|
iv::lidar::PointXYZI point_cloud;
|
|
iv::lidar::PointXYZI * _point_cloud;
|
|
iv::lidar::PointXYZI * _point_cloud;
|
|
- point_cloud.set_x(result.x);
|
|
|
|
- point_cloud.set_y(result.y);
|
|
|
|
|
|
+
|
|
|
|
+ point_cloud.set_x(-result.y);
|
|
|
|
+ point_cloud.set_y(result.x);
|
|
point_cloud.set_z(result.z);
|
|
point_cloud.set_z(result.z);
|
|
|
|
+
|
|
point_cloud.set_i(0);
|
|
point_cloud.set_i(0);
|
|
|
|
|
|
_point_cloud = lidarobj.add_cloud();
|
|
_point_cloud = lidarobj.add_cloud();
|
|
@@ -150,12 +158,20 @@ void GetLidarObj(std::vector<Box> &predResult,iv::lidar::objectarray & lidarobjv
|
|
|
|
|
|
iv::lidar::Dimension ld;
|
|
iv::lidar::Dimension ld;
|
|
iv::lidar::Dimension * pld;
|
|
iv::lidar::Dimension * pld;
|
|
- ld.set_x(result.l);
|
|
|
|
- ld.set_y(result.w);
|
|
|
|
- ld.set_z(result.h);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ld.set_x(result.l);// w
|
|
|
|
+ ld.set_y(result.w);// l
|
|
|
|
+ ld.set_z(result.h);// h
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ld.set_x(result.h);// w
|
|
|
|
+// ld.set_y(result.l);// l
|
|
|
|
+// ld.set_z(result.w);// h
|
|
|
|
+
|
|
|
|
+
|
|
pld = lidarobj.mutable_dimensions();
|
|
pld = lidarobj.mutable_dimensions();
|
|
pld->CopyFrom(ld);
|
|
pld->CopyFrom(ld);
|
|
-
|
|
|
|
iv::lidar::lidarobject * po = lidarobjvec.add_obj();
|
|
iv::lidar::lidarobject * po = lidarobjvec.add_obj();
|
|
po->CopyFrom(lidarobj);
|
|
po->CopyFrom(lidarobj);
|
|
}
|
|
}
|
|
@@ -195,78 +211,48 @@ void DectectOnePCD(const pcl::PointCloud<pcl::PointXYZI>::Ptr &pc_ptr)
|
|
std::cout<<"points num is "<<pointsnum<<std::endl;
|
|
std::cout<<"points num is "<<pointsnum<<std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
- // read source lidar_pointcloud
|
|
|
|
-//void ListenPointCloud(const char *strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
|
-//{
|
|
|
|
-// // std::cout<<" is ok ------------ "<<std::endl;
|
|
|
|
-
|
|
|
|
-// std::cout<<"ListenPointCloud is ok ------------ "<<std::endl;
|
|
|
|
-
|
|
|
|
-// if(nSize <=16)return;
|
|
|
|
-// unsigned int * pHeadSize = (unsigned int *)strdata;
|
|
|
|
-// if(*pHeadSize > nSize)
|
|
|
|
-// {
|
|
|
|
-// givlog->verbose("ListenPointCloud data is small headsize = %d, data size is %d", *pHeadSize, nSize);
|
|
|
|
-// std::cout<<"ListenPointCloud data is small headsize ="<<*pHeadSize<<" data size is"<<nSize<<std::endl;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// gnothavedatatime = 0;
|
|
|
|
-// 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;
|
|
|
|
-// std::shared_ptr<char> str_ptr;
|
|
|
|
-// str_ptr.reset(strName);
|
|
|
|
-// 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;
|
|
|
|
-// memcpy(&xp,p,sizeof(pcl::PointXYZI));
|
|
|
|
-// xp.z = xp.z;
|
|
|
|
-// point_cloud->push_back(xp);
|
|
|
|
-// p++;
|
|
|
|
-// }
|
|
|
|
|
|
+void ListenPointCloud(const char *strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
|
+{
|
|
|
|
+ // std::cout<<" is ok ------------ "<<std::endl;
|
|
|
|
|
|
-// DectectOnePCD(point_cloud);
|
|
|
|
|
|
+ std::cout<<"ListenPointCloud is ok ------------ "<<std::endl;
|
|
|
|
|
|
-// std::cout<<"ListenPointCloud is end ------------ "<<std::endl;
|
|
|
|
-//}
|
|
|
|
|
|
+ if(nSize <=16)return;
|
|
|
|
+ unsigned int * pHeadSize = (unsigned int *)strdata;
|
|
|
|
+ if(*pHeadSize > nSize)
|
|
|
|
+ {
|
|
|
|
+ givlog->verbose("ListenPointCloud data is small headsize = %d, data size is %d", *pHeadSize, nSize);
|
|
|
|
+ std::cout<<"ListenPointCloud data is small headsize ="<<*pHeadSize<<" data size is"<<nSize<<std::endl;
|
|
|
|
+ }
|
|
|
|
|
|
-// read segmentaion_cnn output lidar_pointcloud
|
|
|
|
-void ListenPointCloud(const char *strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
|
-{
|
|
|
|
- iv::lidar::objectarray lidarobjvec;
|
|
|
|
- std::string in;
|
|
|
|
- in.append(strdata,nSize);
|
|
|
|
- lidarobjvec.ParseFromString(in);
|
|
|
|
|
|
+ gnothavedatatime = 0;
|
|
|
|
+ QTime xTime;
|
|
|
|
+ xTime.start();
|
|
|
|
|
|
pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(
|
|
pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(
|
|
new pcl::PointCloud<pcl::PointXYZI>());
|
|
new pcl::PointCloud<pcl::PointXYZI>());
|
|
- for(int i=0; i<lidarobjvec.obj_size();i++){
|
|
|
|
- iv::lidar::lidarobject lidarobj = lidarobjvec.obj(i);
|
|
|
|
- if(lidarobj.type_name()!="car" && lidarobj.type_name()!="pedestrian")
|
|
|
|
- continue;
|
|
|
|
- for(int j=0;j<lidarobj.cloud_size();j++){
|
|
|
|
-// iv::lidar::PointXYZI Point = lidarobj.cloud(j);
|
|
|
|
- pcl::PointXYZI xp;
|
|
|
|
- xp.x = lidarobj.cloud(j).x();
|
|
|
|
- xp.y = lidarobj.cloud(j).y();
|
|
|
|
- xp.z = lidarobj.cloud(j).z();
|
|
|
|
- xp.intensity = lidarobj.cloud(j).i();
|
|
|
|
- point_cloud->push_back(xp);
|
|
|
|
- }
|
|
|
|
|
|
+ int nNameSize;
|
|
|
|
+ nNameSize = *pHeadSize - 4-4-8;
|
|
|
|
+ char * strName = new char[nNameSize+1];strName[nNameSize] = 0;
|
|
|
|
+ std::shared_ptr<char> str_ptr;
|
|
|
|
+ str_ptr.reset(strName);
|
|
|
|
+ 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;
|
|
|
|
+ memcpy(&xp,p,sizeof(pcl::PointXYZI));
|
|
|
|
+ xp.z = xp.z;
|
|
|
|
+ point_cloud->push_back(xp);
|
|
|
|
+ p++;
|
|
}
|
|
}
|
|
|
|
+
|
|
DectectOnePCD(point_cloud);
|
|
DectectOnePCD(point_cloud);
|
|
|
|
|
|
std::cout<<"ListenPointCloud is end ------------ "<<std::endl;
|
|
std::cout<<"ListenPointCloud is end ------------ "<<std::endl;
|
|
@@ -363,6 +349,9 @@ void exitfunc()
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
int main(int argc, char** argv)
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+ QCoreApplication a(argc, argv);
|
|
|
|
+
|
|
gfault = new iv::Ivfault("lidar_centerpoint");
|
|
gfault = new iv::Ivfault("lidar_centerpoint");
|
|
givlog = new iv::Ivlog("lidar_centerpoint");
|
|
givlog = new iv::Ivlog("lidar_centerpoint");
|
|
gfault->SetFaultState(0,0,"centerpoint initialize. ");
|
|
gfault->SetFaultState(0,0,"centerpoint initialize. ");
|
|
@@ -396,16 +385,23 @@ int main(int argc, char** argv)
|
|
// params.fp16 = args.runInFp16;
|
|
// params.fp16 = args.runInFp16;
|
|
// params.load_engine = args.loadEngine;
|
|
// params.load_engine = args.loadEngine;
|
|
|
|
|
|
- params.pfeOnnxFilePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/models/pfe_baseline32000.onnx";
|
|
|
|
- params.rpnOnnxFilePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/models/rpn_baseline.onnx";
|
|
|
|
- params.pfeSerializedEnginePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/models/pfe_fp.engine";
|
|
|
|
- params.rpnSerializedEnginePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/models/rpn_fp.engine";
|
|
|
|
|
|
+ QString strpath = QCoreApplication::applicationDirPath();
|
|
|
|
+ strpath = strpath + "/detection_centerpoint.xml";
|
|
|
|
+ std::cout<<strpath.toStdString()<<std::endl;
|
|
|
|
+
|
|
|
|
+ iv::xmlparam::Xmlparam xparam(strpath.toStdString());
|
|
|
|
+ params.pfeOnnxFilePath = xparam.GetParam("pfeOnnxFilePath","./pfe.onnx");
|
|
|
|
+ params.rpnOnnxFilePath = xparam.GetParam("rpnOnnxFilePath","./rpn.onnx");
|
|
|
|
+ params.pfeSerializedEnginePath = xparam.GetParam("pfeEnginePath","./pfe.engine");
|
|
|
|
+ params.rpnSerializedEnginePath = xparam.GetParam("rpnEnginePath","./rpn.engine");
|
|
params.savePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/results";
|
|
params.savePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/results";
|
|
string filePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/lidars";
|
|
string filePath = "/home/nvidia/modularization/src/detection/CenterPoint-master/lidars";
|
|
params.filePaths=glob(filePath + "/seq_*.bin");
|
|
params.filePaths=glob(filePath + "/seq_*.bin");
|
|
params.fp16 = true;
|
|
params.fp16 = true;
|
|
- params.load_engine = true;
|
|
|
|
|
|
+ params.load_engine = xparam.GetParam("load_engine",true);
|
|
|
|
|
|
|
|
+ //检测分数阈值
|
|
|
|
+ threshold = xparam.GetParam("threshold",0.5);
|
|
|
|
|
|
// Input Output Names, according to TASK_NUM
|
|
// Input Output Names, according to TASK_NUM
|
|
params.pfeInputTensorNames.push_back("input.1");
|
|
params.pfeInputTensorNames.push_back("input.1");
|
|
@@ -460,7 +456,7 @@ int main(int argc, char** argv)
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
}
|
|
}
|
|
|
|
|
|
- return 1;
|
|
|
|
|
|
+ return a.exec();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|