-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/lb-components/src/components/AnnotationView/pointCloudAnnotationView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* @Author: Laoluo luozefeng@sensetime.com | ||
* @Date: 2022-06-13 19:31:36 | ||
* @LastEditors: Laoluo luozefeng@sensetime.com | ||
* @LastEditTime: 2022-06-27 19:43:25 | ||
*/ | ||
|
||
import { PointCloud } from '@labelbee/lb-annotation'; | ||
import { IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils'; | ||
import React, { useCallback, useEffect, useRef } from 'react'; | ||
|
||
interface IProps { | ||
src: string; // 图片路径 | ||
result: string; | ||
size: { | ||
width: number; | ||
height: number; | ||
}; | ||
} | ||
|
||
const PointCloudAnnotationView = (props: IProps) => { | ||
const { src, result, size } = props; | ||
let viewOperation = useRef<any>(); | ||
const instance = useRef<any>(); | ||
|
||
const refCallback = useCallback((node) => { | ||
viewOperation.current = node; | ||
}, []); | ||
|
||
useEffect(() => { | ||
const pointCloud = new PointCloud({ | ||
container: viewOperation.current, | ||
backgroundColor: '#ccc', | ||
}); | ||
instance.current = pointCloud; | ||
}, []); | ||
|
||
useEffect(() => { | ||
instance.current?.init(); | ||
}, [size]); | ||
|
||
useEffect(() => { | ||
if (instance.current && src) { | ||
instance.current?.loadPCDFile(src); | ||
} | ||
}, [src]); | ||
|
||
useEffect(() => { | ||
if (result) { | ||
const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(result); | ||
|
||
// Add Init Box | ||
boxParamsList.forEach((v: IPointCloudBox) => { | ||
instance.current?.generateBox(v, v.id); | ||
}); | ||
} | ||
}, [result]); | ||
|
||
return <div style={size} ref={refCallback} />; | ||
}; | ||
|
||
export default PointCloudAnnotationView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters