|
|
|
|
@ -391,32 +391,32 @@ public class PointCloudProcessor {
|
|
|
|
|
int horizontalCount;//横向个数
|
|
|
|
|
int longitudinalCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
// List<double[]> points = readPCD("E:\\泸州\\c88165e7-9ea6-493e-9130-e74342e5b639--192.168.40.11.pcd");
|
|
|
|
|
// PcdPojo pojo = new PcdPojo();
|
|
|
|
|
// pojo.setConfigPath("E:\\26.json");
|
|
|
|
|
// ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
// PcdPojo pcdPojo
|
|
|
|
|
// try {
|
|
|
|
|
// // 读取 JSON 文件并转换为 配置信息
|
|
|
|
|
// pcdPojo = mapper.readValue(new File("E:\\1.txt"), mapper.getTypeFactory().constructType(PcdPojo.class));
|
|
|
|
|
// // 打印转换后的实体类列表
|
|
|
|
|
// pojo = pojo.setPCDInfo(pojoIn);
|
|
|
|
|
// //报错则认为没有配置文件,返回盘点失败
|
|
|
|
|
// } catch (JsonMappingException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
//
|
|
|
|
|
// } catch (JsonProcessingException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
|
|
//// List<double[]> points = readPCD("E:\\泸州\\c88165e7-9ea6-493e-9130-e74342e5b639--192.168.40.11.pcd");
|
|
|
|
|
//// PcdPojo pojo = new PcdPojo();
|
|
|
|
|
//// pojo.setConfigPath("E:\\26.json");
|
|
|
|
|
//// ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
//// PcdPojo pcdPojo
|
|
|
|
|
//// try {
|
|
|
|
|
//// // 读取 JSON 文件并转换为 配置信息
|
|
|
|
|
//// pcdPojo = mapper.readValue(new File("E:\\1.txt"), mapper.getTypeFactory().constructType(PcdPojo.class));
|
|
|
|
|
//// // 打印转换后的实体类列表
|
|
|
|
|
//// pojo = pojo.setPCDInfo(pojoIn);
|
|
|
|
|
//// //报错则认为没有配置文件,返回盘点失败
|
|
|
|
|
//// } catch (JsonMappingException e) {
|
|
|
|
|
//// e.printStackTrace();
|
|
|
|
|
////
|
|
|
|
|
//// } catch (JsonProcessingException e) {
|
|
|
|
|
//// e.printStackTrace();
|
|
|
|
|
//// } catch (IOException e) {
|
|
|
|
|
//// e.printStackTrace();
|
|
|
|
|
//// }
|
|
|
|
|
// getBaijiuBox("E:\\泸州\\5a11d221-268a-4ed6-ad50-446fa481a56e--192.168.40.11.pcd" ,"E:\\26.json","E:\\1.txt");
|
|
|
|
|
// {//getLongitudinalType(points, pojo, pcdPojo.getWidth(), pcdPojo.getLength(), pcdPojo.getHeight(),pcdPojo.getArrangeType());
|
|
|
|
|
// //getLongitudinalType(points, pojo, 350, 297, new int[]{2443,2142,1750, 1420},"3w 4h 4h");
|
|
|
|
|
// }
|
|
|
|
|
getBaijiuBox("E:\\泸州\\5a11d221-268a-4ed6-ad50-446fa481a56e--192.168.40.11.pcd" ,"E:\\26.json","E:\\1.txt");
|
|
|
|
|
{//getLongitudinalType(points, pojo, pcdPojo.getWidth(), pcdPojo.getLength(), pcdPojo.getHeight(),pcdPojo.getArrangeType());
|
|
|
|
|
//getLongitudinalType(points, pojo, 350, 297, new int[]{2443,2142,1750, 1420},"3w 4h 4h");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
static int getBaijiuBox(String path,String configPath,String typeConfPath){
|
|
|
|
|
List<double[]> points = readPCD(path);
|
|
|
|
|
PcdPojo pojo = new PcdPojo();
|
|
|
|
|
@ -442,7 +442,7 @@ public class PointCloudProcessor {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getLongitudinalType(points, pojo, pcdPojo.getWidth(), pcdPojo.getLength(), pcdPojo.getHeight(),pcdPojo.getArrangeType());
|
|
|
|
|
return getLongitudinalType(points, pojo, pcdPojo.getWidth(), pcdPojo.getLength(), pcdPojo.getHigh(),pcdPojo.getArrangeType());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -605,6 +605,118 @@ public class PointCloudProcessor {
|
|
|
|
|
//计算相似度
|
|
|
|
|
return (int) count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//采用计算面积方式来计算个数
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 将点云数据分割为若列,并计算出每一列的最大和最小值,
|
|
|
|
|
* @param points
|
|
|
|
|
* @param pojo
|
|
|
|
|
* @param l
|
|
|
|
|
* @param w
|
|
|
|
|
* @param height
|
|
|
|
|
* @param type
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static int getLongitudinalType(List<double[]> points, PcdPojo pojo, int l, int w, int height,String type){
|
|
|
|
|
//pojo里面的floorHeight为地板的值,以后所有的height都将根据地板值进行计算地板值减去当前点的z轴值,为高度,且当为height的倍数的时候,认为是有效的点,其中1倍的冗余在50mm,每高一层,冗余增加20mm
|
|
|
|
|
// 计算
|
|
|
|
|
double baseTolerance = 50; // 初始冗余 50mm
|
|
|
|
|
double additionalTolerancePerLevel = 20; // 每层增加 20mm 冗余
|
|
|
|
|
Map<Integer, List<double[]>> map = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
points = points.stream()
|
|
|
|
|
.filter(point -> clipPoints(point, pojo.getMinBounds(), pojo.getMaxBounds()))
|
|
|
|
|
.filter(point -> {
|
|
|
|
|
// 计算当前点的高度(地板值减去 z 轴值)
|
|
|
|
|
double currentHeight = pojo.getFloorHeight() - point[2];
|
|
|
|
|
|
|
|
|
|
// 确保高度为正值
|
|
|
|
|
if (currentHeight < 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算当前高度是 height 的几倍
|
|
|
|
|
int level = (int) Math.round(currentHeight / height);
|
|
|
|
|
|
|
|
|
|
// 计算允许的冗余范围
|
|
|
|
|
double tolerance = baseTolerance + level * additionalTolerancePerLevel;
|
|
|
|
|
|
|
|
|
|
// 判断当前高度是否在允许的范围内
|
|
|
|
|
if (Math.abs(currentHeight - level * height) <= tolerance) {
|
|
|
|
|
if (!map.containsKey(level)) {
|
|
|
|
|
map.put(level, new ArrayList<>());
|
|
|
|
|
}
|
|
|
|
|
map.get(level).add(point);
|
|
|
|
|
return true;
|
|
|
|
|
}else return false;
|
|
|
|
|
})
|
|
|
|
|
.peek(point -> point[2] = pojo.getFloorHeight() - point[2])
|
|
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
String[] types = type.split(" ");
|
|
|
|
|
|
|
|
|
|
int layersCount = 0;
|
|
|
|
|
//计算最大值
|
|
|
|
|
for (String s : types){
|
|
|
|
|
if (s.endsWith("w")){
|
|
|
|
|
int maxW= Integer.parseInt(s.substring(0,1));
|
|
|
|
|
layersCount +=maxW;
|
|
|
|
|
}else if (s.endsWith("h")){
|
|
|
|
|
int maxL= Integer.parseInt(s.substring(0,1));
|
|
|
|
|
layersCount +=maxL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int h =5; h>0; h--){
|
|
|
|
|
if (map.containsKey(h) && map.get(h).size()>500){
|
|
|
|
|
double area =IntervalPolygonArea.calculateArea(map.get(h),pojo.minBounds[0],10);
|
|
|
|
|
if (area>0){
|
|
|
|
|
int i =(layersCount*(h-1))+(int) Math.round(area/(double) (l*w));
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String path ="E:\\工作\\泸州测试\\2025-05-12\\7d5a619e-190d-4e7d-95a9-1e47aa49eef8--192.168.48.11.pcd";
|
|
|
|
|
String configPath = "E:\\工作\\泸州测试\\27.json";
|
|
|
|
|
String typeConfPath = "E:\\工作\\泸州测试\\temlent\\40014847.json";
|
|
|
|
|
List<double[]> points = readPCD(path);
|
|
|
|
|
PcdPojo pojo = new PcdPojo();
|
|
|
|
|
PcdPojo pcdPojo = new PcdPojo();
|
|
|
|
|
pojo.setConfigPath(configPath);
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
try {
|
|
|
|
|
// 读取 JSON 文件并转换为 配置信息
|
|
|
|
|
PcdPojo pojoIn = mapper.readValue(new File(pojo.getConfigPath()), mapper.getTypeFactory().constructType(PcdPojo.class));
|
|
|
|
|
// 打印转换后的实体类列表
|
|
|
|
|
pojo = pojo.setPCDInfo(pojoIn);
|
|
|
|
|
// 读取 JSON 文件并转换为 配置信息
|
|
|
|
|
pcdPojo = mapper.readValue(new File(typeConfPath), mapper.getTypeFactory().constructType(PcdPojo.class));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//报错则认为没有配置文件,返回盘点失败
|
|
|
|
|
} catch (JsonMappingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i = getLongitudinalType(points,pojo, pcdPojo.getWidth(), pcdPojo.getLength(), pcdPojo.getHigh(),pcdPojo.getArrangeType());
|
|
|
|
|
System.out.println(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int getTopCount(List<double[]> points, PcdPojo pojo, int l, int w,Map<Integer, In> map ,int minIndex,int maxIndex,int maxW,int maxL,int h){
|
|
|
|
|
int count = 0;
|
|
|
|
|
//列相等
|
|
|
|
|
|