@labelbee/lb-annotation 1.8.0 → 1.9.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +65 -0
  2. package/dist/index.js +20 -9
  3. package/dist/types/constant/tool.d.ts +3 -1
  4. package/dist/types/core/index.d.ts +24 -4
  5. package/dist/types/core/pointCloud/OrbitControls.d.ts +60 -0
  6. package/dist/types/core/pointCloud/PCDLoader.d.ts +11 -0
  7. package/dist/types/core/pointCloud/annotation.d.ts +47 -0
  8. package/dist/types/core/pointCloud/cache.d.ts +16 -0
  9. package/dist/types/core/pointCloud/index.d.ts +325 -0
  10. package/dist/types/core/scheduler.d.ts +71 -0
  11. package/dist/types/core/toolOperation/basicToolOperation.d.ts +20 -2
  12. package/dist/types/core/toolOperation/eventListener.d.ts +2 -2
  13. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +80 -0
  14. package/dist/types/core/toolOperation/polygonOperation.d.ts +21 -7
  15. package/dist/types/core/toolOperation/segmentByRect.d.ts +31 -0
  16. package/dist/types/index.d.ts +9 -3
  17. package/dist/types/newCore/CanvasScheduler.d.ts +31 -0
  18. package/dist/types/newCore/index.d.ts +1 -0
  19. package/dist/types/utils/MathUtils.d.ts +6 -0
  20. package/dist/types/utils/tool/CommonToolUtils.d.ts +0 -13
  21. package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +20 -0
  22. package/dist/types/utils/tool/PolygonUtils.d.ts +1 -0
  23. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -0
  24. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -0
  25. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -0
  26. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -0
  27. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -0
  28. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -0
  29. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -0
  30. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -0
  31. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -0
  32. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -0
  33. package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -0
  34. package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -0
  35. package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -0
  36. package/es/assets/attributeIcon/icon_editLV.svg.js +3 -0
  37. package/es/assets/attributeIcon/icon_editQING.svg.js +3 -0
  38. package/es/constant/annotation.js +68 -0
  39. package/es/constant/annotationTask.js +25 -0
  40. package/es/constant/defaultConfig.js +260 -0
  41. package/es/constant/keyCode.js +36 -0
  42. package/es/constant/style.js +67 -0
  43. package/es/constant/tool.js +183 -0
  44. package/es/core/index.js +145 -0
  45. package/es/core/pointCloud/OrbitControls.js +661 -0
  46. package/es/core/pointCloud/PCDLoader.js +238 -0
  47. package/es/core/pointCloud/annotation.js +98 -0
  48. package/es/core/pointCloud/cache.js +42 -0
  49. package/es/core/pointCloud/index.js +771 -0
  50. package/es/core/scheduler.js +184 -0
  51. package/es/core/toolOperation/LineToolOperation.js +1369 -0
  52. package/es/core/toolOperation/TextToolOperation.js +129 -0
  53. package/es/core/toolOperation/ViewOperation.js +410 -0
  54. package/es/core/toolOperation/basicToolOperation.js +817 -0
  55. package/es/core/toolOperation/checkOperation.js +206 -0
  56. package/es/core/toolOperation/eventListener.js +35 -0
  57. package/es/core/toolOperation/measureOperation.js +39 -0
  58. package/es/core/toolOperation/pointCloud2dOperation.js +197 -0
  59. package/es/core/toolOperation/pointOperation.js +603 -0
  60. package/es/core/toolOperation/polygonOperation.js +1201 -0
  61. package/es/core/toolOperation/rectOperation.js +1170 -0
  62. package/es/core/toolOperation/segmentByRect.js +172 -0
  63. package/es/core/toolOperation/tagOperation.js +215 -0
  64. package/es/core/toolOperation/textAttributeClass.js +201 -0
  65. package/es/index.js +25 -14
  66. package/es/locales/constants.js +21 -0
  67. package/es/locales/en_US/message.js +22 -0
  68. package/es/locales/index.js +17 -0
  69. package/es/locales/zh_CN/message.js +22 -0
  70. package/es/newCore/CanvasScheduler.js +31 -0
  71. package/es/utils/ActionsHistory.js +78 -0
  72. package/es/utils/ImgUtils.js +20 -0
  73. package/es/utils/MathUtils.js +283 -0
  74. package/es/utils/VectorUtils.js +23 -0
  75. package/es/utils/tool/AttributeUtils.js +196 -0
  76. package/es/utils/tool/AxisUtils.js +254 -0
  77. package/es/utils/tool/CanvasUtils.js +60 -0
  78. package/es/utils/tool/CommonToolUtils.js +172 -0
  79. package/es/utils/tool/CurrentOperation.js +35 -0
  80. package/es/utils/tool/DblClickEventListener.js +100 -0
  81. package/es/utils/tool/DrawUtils.js +424 -0
  82. package/es/utils/tool/EnhanceCommonToolUtils.js +39 -0
  83. package/es/utils/tool/ImgPosUtils.js +56 -0
  84. package/es/utils/tool/LineToolUtils.js +255 -0
  85. package/es/utils/tool/MarkerUtils.js +9 -0
  86. package/es/utils/tool/PolygonUtils.js +458 -0
  87. package/es/utils/tool/RectUtils.js +153 -0
  88. package/es/utils/tool/RenderDomClass.js +68 -0
  89. package/es/utils/tool/RenderDomUtils.js +29 -0
  90. package/es/utils/tool/StyleUtils.js +29 -0
  91. package/es/utils/tool/TagUtils.js +127 -0
  92. package/es/utils/tool/UnitUtils.js +10 -0
  93. package/es/utils/tool/ZoomUtils.js +70 -0
  94. package/es/utils/tool/polygonTool.js +126 -0
  95. package/es/utils/uuid.js +24 -0
  96. package/package.json +6 -4
package/README.md CHANGED
@@ -143,3 +143,68 @@ interface IPolygonData {
143
143
  attribute: string;
144
144
  }
145
145
  ```
146
+
147
+ ### 多层级标注
148
+
149
+ 该方式可以将多个工具进行融合,实现多个工具在统一层次进行展示。
150
+
151
+ 下方以一个多边形 + 分割辅助操作进行为例子
152
+
153
+ ```ts
154
+ import React, { useEffect } from 'react';
155
+ import { AnnotationEngine } from '@labelbee/lb-annotation';
156
+
157
+ const imgSrc =
158
+ 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Andre_Iguodala_2016.jpg/1200px-Andre_Iguodala_2016.jpg';
159
+
160
+ type TRunPrediction = (params: {
161
+ point: { x: number; y: number };
162
+ rect: { x: number; y: number; w: number; h: number };
163
+ }) => Promise<unknown>;
164
+
165
+ const App = () => {
166
+ const ref = React.useRef(null);
167
+
168
+ useEffect(() => {
169
+ if (ref.current) {
170
+ const imgNode = new Image();
171
+ imgNode.src = imgSrc;
172
+ imgNode.onload = () => {
173
+ // 获取当前工具的类
174
+ const annotationEngine = new AnnotationEngine({
175
+ container: ref.current,
176
+ size: {
177
+ width: 1000,
178
+ height: 600,
179
+ },
180
+ toolName: ['segmentByRectTool', 'polygonTool'], // 创建通过多层级进行创建
181
+ imgNode,
182
+ });
183
+
184
+ // 1. 切换层级 (临时使用该方式切换两个层级的变换)
185
+ annotationEngine.switchLastTwoCanvas();
186
+
187
+ // 2. 获取分割层次的 instance, 设置 runPrediction 函数
188
+ const firstToolInstance = annotationEngine.firstToolInstance;
189
+
190
+ const runPrediction = (params: TRunPrediction) => {
191
+ return new Promise((resolve) => {
192
+ // 模拟异步的操作
193
+ setTimeout(() => {
194
+ // 关键,需要返回成功
195
+ resolve('');
196
+ message.success('Predict successfully');
197
+ annotationEngine.switchLastTwoCanvas();
198
+ }, 1000);
199
+ });
200
+ };
201
+ firstToolInstance?.setRunPrediction?.(runPrediction);
202
+ };
203
+ }
204
+ }, []);
205
+
206
+ return <div ref={ref} />;
207
+ };
208
+
209
+ export default App;
210
+ ```