|
@@ -0,0 +1,440 @@
|
|
|
|
+package com.hfln.device.domain.service;
|
|
|
|
+
|
|
|
|
+import com.hfln.device.domain.constant.DeviceConstants;
|
|
|
|
+import com.hfln.device.domain.entity.Device;
|
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
+import org.junit.jupiter.api.DisplayName;
|
|
|
|
+import org.junit.jupiter.api.Nested;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * PointCloudProcessService 单元测试
|
|
|
|
+ * 测试点云后处理、AI算法集成相关功能
|
|
|
|
+ */
|
|
|
|
+@DisplayName("点云处理服务测试")
|
|
|
|
+class PointCloudProcessServiceTest {
|
|
|
|
+
|
|
|
|
+ private PointCloudProcessService pointCloudProcessService;
|
|
|
|
+
|
|
|
|
+ @BeforeEach
|
|
|
|
+ void setUp() {
|
|
|
|
+ pointCloudProcessService = new PointCloudProcessService();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nested
|
|
|
|
+ @DisplayName("点云目标提取测试")
|
|
|
|
+ class TrackerTargetsTest {
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("基础目标提取测试 - 单个点")
|
|
|
|
+ void testGetTrackerTargetsSinglePoint() {
|
|
|
|
+ List<List<Float>> pointCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100.0f, 200.0f, 50.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ List<List<Float>> result = pointCloudProcessService.getTrackerTargets(pointCloud);
|
|
|
|
+
|
|
|
|
+ assertNotNull(result);
|
|
|
|
+ assertEquals(1, result.size());
|
|
|
|
+ assertEquals(3, result.get(0).size());
|
|
|
|
+ assertEquals(100.0f, result.get(0).get(0), 0.001f);
|
|
|
|
+ assertEquals(200.0f, result.get(0).get(1), 0.001f);
|
|
|
|
+ assertEquals(50.0f, result.get(0).get(2), 0.001f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("多点云平均值计算测试")
|
|
|
|
+ void testGetTrackerTargetsMultiplePoints() {
|
|
|
|
+ List<List<Float>> pointCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100.0f, 200.0f, 50.0f),
|
|
|
|
+ Arrays.asList(200.0f, 400.0f, 100.0f),
|
|
|
|
+ Arrays.asList(300.0f, 600.0f, 150.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ List<List<Float>> result = pointCloudProcessService.getTrackerTargets(pointCloud);
|
|
|
|
+
|
|
|
|
+ assertNotNull(result);
|
|
|
|
+ assertEquals(1, result.size());
|
|
|
|
+ // 验证平均值计算:(100+200+300)/3=200, (200+400+600)/3=400, (50+100+150)/3=100
|
|
|
|
+ assertEquals(200.0f, result.get(0).get(0), 0.001f);
|
|
|
|
+ assertEquals(400.0f, result.get(0).get(1), 0.001f);
|
|
|
|
+ assertEquals(100.0f, result.get(0).get(2), 0.001f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("空点云处理测试")
|
|
|
|
+ void testGetTrackerTargetsEmptyCloud() {
|
|
|
|
+ // 测试null输入
|
|
|
|
+ List<List<Float>> result1 = pointCloudProcessService.getTrackerTargets(null);
|
|
|
|
+ assertTrue(result1.isEmpty());
|
|
|
|
+
|
|
|
|
+ // 测试空列表
|
|
|
|
+ List<List<Float>> result2 = pointCloudProcessService.getTrackerTargets(new ArrayList<>());
|
|
|
|
+ assertTrue(result2.isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("getTrackerTargetsMult功能测试")
|
|
|
|
+ void testGetTrackerTargetsMult() {
|
|
|
|
+ List<List<Float>> pointCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(10.0f, 20.0f, 30.0f),
|
|
|
|
+ Arrays.asList(40.0f, 50.0f, 60.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ List<List<Float>> result1 = pointCloudProcessService.getTrackerTargets(pointCloud);
|
|
|
|
+ List<List<Float>> result2 = pointCloudProcessService.getTrackerTargetsMult(pointCloud);
|
|
|
|
+
|
|
|
|
+ // 验证两个方法返回相同结果(对应Python版本的相同实现)
|
|
|
|
+ assertEquals(result1.size(), result2.size());
|
|
|
|
+ assertEquals(result1.get(0).get(0), result2.get(0).get(0), 0.001f);
|
|
|
|
+ assertEquals(result1.get(0).get(1), result2.get(0).get(1), 0.001f);
|
|
|
|
+ assertEquals(result1.get(0).get(2), result2.get(0).get(2), 0.001f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("不同维度点云处理测试")
|
|
|
|
+ void testDifferentDimensionPoints() {
|
|
|
|
+ // 测试2D点云(只有x,y坐标)
|
|
|
|
+ List<List<Float>> pointCloud2D = Arrays.asList(
|
|
|
|
+ Arrays.asList(10.0f, 20.0f),
|
|
|
|
+ Arrays.asList(30.0f, 40.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ List<List<Float>> result2D = pointCloudProcessService.getTrackerTargets(pointCloud2D);
|
|
|
|
+ assertNotNull(result2D);
|
|
|
|
+ assertEquals(1, result2D.size());
|
|
|
|
+ assertEquals(2, result2D.get(0).size());
|
|
|
|
+ assertEquals(20.0f, result2D.get(0).get(0), 0.001f); // (10+30)/2
|
|
|
|
+ assertEquals(30.0f, result2D.get(0).get(1), 0.001f); // (20+40)/2
|
|
|
|
+
|
|
|
|
+ // 测试4D点云(包含额外维度)
|
|
|
|
+ List<List<Float>> pointCloud4D = Arrays.asList(
|
|
|
|
+ Arrays.asList(10.0f, 20.0f, 30.0f, 40.0f),
|
|
|
|
+ Arrays.asList(50.0f, 60.0f, 70.0f, 80.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ List<List<Float>> result4D = pointCloudProcessService.getTrackerTargets(pointCloud4D);
|
|
|
|
+ assertNotNull(result4D);
|
|
|
|
+ assertEquals(1, result4D.size());
|
|
|
|
+ assertEquals(4, result4D.get(0).size());
|
|
|
|
+ assertEquals(30.0f, result4D.get(0).get(0), 0.001f); // (10+50)/2
|
|
|
|
+ assertEquals(40.0f, result4D.get(0).get(1), 0.001f); // (20+60)/2
|
|
|
|
+ assertEquals(50.0f, result4D.get(0).get(2), 0.001f); // (30+70)/2
|
|
|
|
+ assertEquals(60.0f, result4D.get(0).get(3), 0.001f); // (40+80)/2
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nested
|
|
|
|
+ @DisplayName("AI算法后处理测试")
|
|
|
|
+ class PostProcessTest {
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("AI数据预处理测试 - 李博模型格式")
|
|
|
|
+ void testPreparePostDataLibo() {
|
|
|
|
+ List<List<Float>> rawPoints = Arrays.asList(
|
|
|
|
+ Arrays.asList(10.0f, 20.0f, 30.0f, 40.0f), // 4维数据,应该只取前3维
|
|
|
|
+ Arrays.asList(50.0f, 60.0f, 70.0f, 80.0f),
|
|
|
|
+ Arrays.asList(90.0f, 100.0f, 110.0f, 120.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ Map<String, Object> result = pointCloudProcessService.preparePostData(rawPoints);
|
|
|
|
+
|
|
|
|
+ assertNotNull(result);
|
|
|
|
+ assertTrue(result.containsKey("point_cloud"));
|
|
|
|
+
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
+ List<List<Float>> processedPoints = (List<List<Float>>) result.get("point_cloud");
|
|
|
|
+ assertEquals(3, processedPoints.size());
|
|
|
|
+
|
|
|
|
+ // 验证每个点只保留了前3个坐标
|
|
|
|
+ for (List<Float> point : processedPoints) {
|
|
|
|
+ assertEquals(3, point.size());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 验证第一个点的坐标
|
|
|
|
+ assertEquals(10.0f, processedPoints.get(0).get(0), 0.001f);
|
|
|
|
+ assertEquals(20.0f, processedPoints.get(0).get(1), 0.001f);
|
|
|
|
+ assertEquals(30.0f, processedPoints.get(0).get(2), 0.001f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("空数据预处理测试")
|
|
|
|
+ void testPreparePostDataEmpty() {
|
|
|
|
+ // 测试null输入
|
|
|
|
+ Map<String, Object> result1 = pointCloudProcessService.preparePostData(null);
|
|
|
|
+ assertTrue(result1.isEmpty());
|
|
|
|
+
|
|
|
|
+ // 测试空列表
|
|
|
|
+ Map<String, Object> result2 = pointCloudProcessService.preparePostData(new ArrayList<>());
|
|
|
|
+ assertTrue(result2.isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("姿态分类映射测试")
|
|
|
|
+ void testCheckPose() {
|
|
|
|
+ // 测试各种姿态分类映射
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_FALLING.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(0));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_SITTING_ON_CHAIR.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(1));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_SITTING_ON_FLOOR.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(2));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_SQUATTING.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(3));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_STANDING.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(4));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_SITTING.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(5));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_LYING.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(6));
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_INVALID.getCode(),
|
|
|
|
+ pointCloudProcessService.checkPose(999)); // 无效值
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("AI响应处理测试")
|
|
|
|
+ void testProcessPoseResponse() {
|
|
|
|
+ // 测试正常响应
|
|
|
|
+ Map<String, Object> responseJson = new HashMap<>();
|
|
|
|
+ responseJson.put("predicted_class", 4);
|
|
|
|
+
|
|
|
|
+ int result = pointCloudProcessService.processPoseResponse(responseJson);
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_STANDING.getCode(), result);
|
|
|
|
+
|
|
|
|
+ // 测试无效响应
|
|
|
|
+ Map<String, Object> invalidResponse = new HashMap<>();
|
|
|
|
+ invalidResponse.put("other_field", "value");
|
|
|
|
+
|
|
|
|
+ int invalidResult = pointCloudProcessService.processPoseResponse(invalidResponse);
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_INVALID.getCode(), invalidResult);
|
|
|
|
+
|
|
|
|
+ // 测试空响应
|
|
|
|
+ int emptyResult = pointCloudProcessService.processPoseResponse(new HashMap<>());
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_INVALID.getCode(), emptyResult);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nested
|
|
|
|
+ @DisplayName("多设备点云处理测试")
|
|
|
|
+ class MultiDeviceTest {
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("获取最大长度点云测试")
|
|
|
|
+ void testGetMaxLenRawPoints() {
|
|
|
|
+ // 创建测试设备
|
|
|
|
+ Device device1 = new Device("DEV001");
|
|
|
|
+ device1.setDevType("LNA");
|
|
|
|
+
|
|
|
|
+ Device device2 = new Device("DEV002");
|
|
|
|
+ device2.setDevType("LNA");
|
|
|
|
+
|
|
|
|
+ Device device3 = new Device("DEV003");
|
|
|
|
+ device3.setDevType("LNB"); // LNB设备应该被忽略
|
|
|
|
+
|
|
|
|
+ // 为设备添加不同长度的点云数据
|
|
|
|
+ List<List<Float>> cloudPoints1 = Arrays.asList(
|
|
|
|
+ Arrays.asList(1.0f, 2.0f, 3.0f),
|
|
|
|
+ Arrays.asList(4.0f, 5.0f, 6.0f)
|
|
|
|
+ ); // 长度: 2
|
|
|
|
+ device1.putCloudPointsQueue(cloudPoints1);
|
|
|
|
+
|
|
|
|
+ List<List<Float>> cloudPoints2 = Arrays.asList(
|
|
|
|
+ Arrays.asList(7.0f, 8.0f, 9.0f),
|
|
|
|
+ Arrays.asList(10.0f, 11.0f, 12.0f),
|
|
|
|
+ Arrays.asList(13.0f, 14.0f, 15.0f),
|
|
|
|
+ Arrays.asList(16.0f, 17.0f, 18.0f),
|
|
|
|
+ Arrays.asList(19.0f, 20.0f, 21.0f)
|
|
|
|
+ ); // 长度: 5
|
|
|
|
+ device2.putCloudPointsQueue(cloudPoints2);
|
|
|
|
+
|
|
|
|
+ List<List<Float>> cloudPoints3 = Arrays.asList(
|
|
|
|
+ Arrays.asList(22.0f, 23.0f, 24.0f),
|
|
|
|
+ Arrays.asList(25.0f, 26.0f, 27.0f),
|
|
|
|
+ Arrays.asList(28.0f, 29.0f, 30.0f)
|
|
|
|
+ ); // 长度: 3
|
|
|
|
+ device3.putCloudPointsQueue(cloudPoints3);
|
|
|
|
+
|
|
|
|
+ Collection<Device> devices = Arrays.asList(device1, device2, device3);
|
|
|
|
+
|
|
|
|
+ // 获取最大长度的点云
|
|
|
|
+ Map<String, Object> result = pointCloudProcessService.getMaxLenRawPoints(devices);
|
|
|
|
+
|
|
|
|
+ assertNotNull(result);
|
|
|
|
+ assertEquals("DEV002", result.get("dev_id"));
|
|
|
|
+
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
+ List<List<Float>> rawPoints = (List<List<Float>>) result.get("raw_points");
|
|
|
|
+ assertEquals(5, rawPoints.size()); // 应该返回长度为5的点云
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("所有设备点云数据不足测试")
|
|
|
|
+ void testGetMaxLenRawPointsInsufficientData() {
|
|
|
|
+ Device device1 = new Device("DEV001");
|
|
|
|
+ device1.setDevType("LNA");
|
|
|
|
+
|
|
|
|
+ Device device2 = new Device("DEV002");
|
|
|
|
+ device2.setDevType("LNA");
|
|
|
|
+
|
|
|
|
+ // 添加少于20个点的点云数据
|
|
|
|
+ List<List<Float>> smallCloudPoints = Arrays.asList(
|
|
|
|
+ Arrays.asList(1.0f, 2.0f, 3.0f),
|
|
|
|
+ Arrays.asList(4.0f, 5.0f, 6.0f)
|
|
|
|
+ ); // 长度: 2 < 20
|
|
|
|
+
|
|
|
|
+ device1.putCloudPointsQueue(smallCloudPoints);
|
|
|
|
+ device2.putCloudPointsQueue(smallCloudPoints);
|
|
|
|
+
|
|
|
|
+ Collection<Device> devices = Arrays.asList(device1, device2);
|
|
|
|
+
|
|
|
|
+ Map<String, Object> result = pointCloudProcessService.getMaxLenRawPoints(devices);
|
|
|
|
+ assertNull(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("空设备集合处理测试")
|
|
|
|
+ void testGetMaxLenRawPointsEmptyDevices() {
|
|
|
|
+ Collection<Device> emptyDevices = new ArrayList<>();
|
|
|
|
+ Map<String, Object> result = pointCloudProcessService.getMaxLenRawPoints(emptyDevices);
|
|
|
|
+ assertNull(result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nested
|
|
|
|
+ @DisplayName("姿态识别测试")
|
|
|
|
+ class PoseRecognitionTest {
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("基础姿态识别测试")
|
|
|
|
+ void testProcessPoseRecognition() {
|
|
|
|
+ List<List<Number>> pointCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100, 200, 80), // 高度较高,应该识别为站立
|
|
|
|
+ Arrays.asList(110, 210, 85),
|
|
|
|
+ Arrays.asList(90, 190, 75)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ PointCloudProcessService.PoseResult result =
|
|
|
|
+ pointCloudProcessService.processPoseRecognition(pointCloud);
|
|
|
|
+
|
|
|
|
+ assertNotNull(result);
|
|
|
|
+ assertTrue(result.getPose() >= 0); // 应该返回有效的姿态代码
|
|
|
|
+ assertTrue(result.getConfidence() > 0); // 应该有置信度
|
|
|
|
+ assertNotNull(result.getTargetPoint()); // 应该有目标点
|
|
|
|
+ assertEquals(3, result.getTargetPoint().size()); // 目标点应该是3维
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("不同高度分布姿态识别测试")
|
|
|
|
+ void testPoseRecognitionDifferentHeights() {
|
|
|
|
+ // 测试低高度点云(躺着)
|
|
|
|
+ List<List<Number>> lowHeightCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100, 200, 10),
|
|
|
|
+ Arrays.asList(110, 210, 15),
|
|
|
|
+ Arrays.asList(90, 190, 5)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ PointCloudProcessService.PoseResult lowResult =
|
|
|
|
+ pointCloudProcessService.processPoseRecognition(lowHeightCloud);
|
|
|
|
+
|
|
|
|
+ // 应该识别为躺着或坐在地上
|
|
|
|
+ assertTrue(lowResult.getPose() == DeviceConstants.PoseEnum.POSE_FALLING.getCode() ||
|
|
|
|
+ lowResult.getPose() == DeviceConstants.PoseEnum.POSE_SITTING_ON_FLOOR.getCode());
|
|
|
|
+
|
|
|
|
+ // 测试中等高度点云(坐着)
|
|
|
|
+ List<List<Number>> mediumHeightCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100, 200, 60),
|
|
|
|
+ Arrays.asList(110, 210, 65),
|
|
|
|
+ Arrays.asList(90, 190, 55)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ PointCloudProcessService.PoseResult mediumResult =
|
|
|
|
+ pointCloudProcessService.processPoseRecognition(mediumHeightCloud);
|
|
|
|
+
|
|
|
|
+ // 应该识别为坐着或蹲着
|
|
|
|
+ assertTrue(mediumResult.getPose() == DeviceConstants.PoseEnum.POSE_SITTING.getCode() ||
|
|
|
|
+ mediumResult.getPose() == DeviceConstants.PoseEnum.POSE_SQUATTING.getCode());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("空点云姿态识别测试")
|
|
|
|
+ void testPoseRecognitionEmptyCloud() {
|
|
|
|
+ PointCloudProcessService.PoseResult result =
|
|
|
|
+ pointCloudProcessService.processPoseRecognition(null);
|
|
|
|
+
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_INVALID.getCode(), result.getPose());
|
|
|
|
+ assertEquals(0.0f, result.getConfidence(), 0.001f);
|
|
|
|
+ assertTrue(result.getTargetPoint().isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("analyzePose适配方法测试")
|
|
|
|
+ void testAnalyzePose() {
|
|
|
|
+ List<List<Float>> pointCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100.0f, 200.0f, 80.0f),
|
|
|
|
+ Arrays.asList(110.0f, 210.0f, 85.0f),
|
|
|
|
+ Arrays.asList(90.0f, 190.0f, 75.0f)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ int pose = pointCloudProcessService.analyzePose(pointCloud);
|
|
|
|
+ assertTrue(pose >= 0); // 应该返回有效的姿态代码
|
|
|
|
+
|
|
|
|
+ // 测试空输入
|
|
|
|
+ int invalidPose = pointCloudProcessService.analyzePose(null);
|
|
|
|
+ assertEquals(DeviceConstants.PoseEnum.POSE_INVALID.getCode(), invalidPose);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nested
|
|
|
|
+ @DisplayName("性能测试")
|
|
|
|
+ class PerformanceTest {
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("大量点云处理性能测试")
|
|
|
|
+ void testLargePointCloudProcessing() {
|
|
|
|
+ // 生成大量点云数据
|
|
|
|
+ List<List<Float>> largePointCloud = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < 10000; i++) {
|
|
|
|
+ largePointCloud.add(Arrays.asList(
|
|
|
|
+ (float)(Math.random() * 1000),
|
|
|
|
+ (float)(Math.random() * 1000),
|
|
|
|
+ (float)(Math.random() * 100)
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+ List<List<Float>> result = pointCloudProcessService.getTrackerTargets(largePointCloud);
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ assertNotNull(result);
|
|
|
|
+ assertEquals(1, result.size());
|
|
|
|
+
|
|
|
|
+ long duration = endTime - startTime;
|
|
|
|
+ assertTrue(duration < 1000, "大量点云处理耗时过长: " + duration + "ms");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ @DisplayName("批量姿态识别性能测试")
|
|
|
|
+ void testBatchPoseRecognitionPerformance() {
|
|
|
|
+ List<List<Number>> testCloud = Arrays.asList(
|
|
|
|
+ Arrays.asList(100, 200, 50),
|
|
|
|
+ Arrays.asList(110, 210, 55),
|
|
|
|
+ Arrays.asList(90, 190, 45)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < 1000; i++) {
|
|
|
|
+ pointCloudProcessService.processPoseRecognition(testCloud);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+ long duration = endTime - startTime;
|
|
|
|
+
|
|
|
|
+ assertTrue(duration < 2000, "批量姿态识别耗时过长: " + duration + "ms");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|