MCPcopy Create free account
hub / github.com/BIT-MJY/CVTNet / main

Function main

CVTNet_libtorch/ws/fast_cvtnet.cpp:127–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125
126
127int main()
128{
129
130 torch::DeviceType device_type;
131 device_type = torch::kCUDA;
132 torch::Device device(device_type);
133 std::cout<<"cuda support:"<< (torch::cuda::is_available()?"ture":"false")<<std::endl;
134 torch::jit::script::Module module = torch::jit::load("../../CVTNet.pt");
135 module.to(torch::kCUDA);
136 module.eval();
137
138 std::string lidar_file = "../1.pcd";
139 std::vector<float> lidar_data = read_lidar_data(lidar_file);
140 pcl::PointCloud<pcl::PointXYZI>::Ptr cloud0(new pcl::PointCloud<pcl::PointXYZI>);
141
142 for (std::size_t i = 0; i < lidar_data.size(); i += 1)
143 {
144 pcl::PointXYZI point;
145 point.x = lidar_data[i];
146 point.y = lidar_data[i + 1];
147 point.z = lidar_data[i + 2];
148 point.intensity = lidar_data[i + 3];
149 cloud0->points.push_back(point);
150 }
151
152 int width = 900;
153 int height = 32;
154 std::vector<float> range_thresh = {0.0, 15.0, 30.0, 45.0, 60.0};
155 std::vector<float> height_thresh = {-4.0, 0.0, 4.0, 8.0, 12.0};
156 int interval = range_thresh.size();
157 int len_arr = width*height;
158 int len_arr_all = 2*interval*width*height;
159 float ri_bev_image[len_arr_all];
160
161 for(int th=0; th<range_thresh.size(); th++)
162 {
163 float range_image[len_arr];
164 float farer_bound = range_thresh[th+1];
165 float nearer_bound = range_thresh[th];
166 if (th == range_thresh.size()-1)
167 {
168 gen_range_image(range_image, cloud0, 15, -16, 32, 900, 80, range_thresh[int(interval-1)], range_thresh[0]);
169 }
170 else
171 {
172 gen_range_image(range_image, cloud0, 15, -16, 32, 900, 80, farer_bound, nearer_bound);
173 }
174 for(int x=0; x<width; x++)
175 {
176 for(int y=0; y<height; y++)
177 {
178 int idx_in_all = int(th*width*height + y*width + x);
179 ri_bev_image[idx_in_all] = range_image[y*width + x];
180 }
181 }
182 }
183
184 for(int th=0; th<height_thresh.size(); th++)

Callers

nothing calls this directly

Calls 5

read_lidar_dataFunction · 0.85
gen_range_imageFunction · 0.85
gen_bev_imageFunction · 0.85
evalMethod · 0.45
forwardMethod · 0.45

Tested by

no test coverage detected