From d3406b497f5c1ad19cda3630b2686e939e050d7c Mon Sep 17 00:00:00 2001 From: laoluo Date: Wed, 14 Sep 2022 14:43:10 +0800 Subject: [PATCH] feat(pointcloud-2d): Filter maaping error data --- .../lb-annotation/src/core/pointCloud/index.ts | 17 ++++++++++------- .../pointCloudView/PointCloud2DView.tsx | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/lb-annotation/src/core/pointCloud/index.ts b/packages/lb-annotation/src/core/pointCloud/index.ts index de92f6663..b5701ce8d 100644 --- a/packages/lb-annotation/src/core/pointCloud/index.ts +++ b/packages/lb-annotation/src/core/pointCloud/index.ts @@ -266,13 +266,16 @@ export class PointCloud { const { P, R, T } = cameraMatrix; const { composeMatrix4 } = this.transferKitti2Matrix(P, R, T); - const transferViewData = allViewData.map((viewData) => ({ - type: viewData.type, - pointList: viewData.pointList - .map((point) => this.rotatePoint(point, boxParams.center, boxParams.rotation)) - .map((point) => this.lidar2image(point, composeMatrix4)) - .filter((v) => v !== undefined), - })); + const transferViewData = allViewData + .map((viewData) => ({ + type: viewData.type, + pointList: viewData.pointList + .map((point) => this.rotatePoint(point, boxParams.center, boxParams.rotation)) + .map((point) => this.lidar2image(point, composeMatrix4)) + .filter((v) => v !== undefined), + })) + // Clear Empty PointList + .filter((v) => v.pointList.length !== 0); return transferViewData; } diff --git a/packages/lb-components/src/components/pointCloudView/PointCloud2DView.tsx b/packages/lb-components/src/components/pointCloudView/PointCloud2DView.tsx index eb73529d7..1550fe88d 100644 --- a/packages/lb-components/src/components/pointCloudView/PointCloud2DView.tsx +++ b/packages/lb-components/src/components/pointCloudView/PointCloud2DView.tsx @@ -103,7 +103,10 @@ const PointCloud2DView = ({ imgInfo }: IProps) => { return; } const selected2data = annotations2d.find((v) => v.annotation.id === selectedBox.info.id); - toolInstance.focusPositionByPointList(selected2data?.annotation.pointList); + + if (selected2data?.annotation.pointList?.length > 0) { + toolInstance.focusPositionByPointList(selected2data?.annotation.pointList); + } }, [selectedBox, viewRef.current, annotations2d]); return (