@labelbee/lb-components 1.23.0-alpha.30 → 1.23.0-alpha.32
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.
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils/index.d.ts +21 -0
- package/dist/utils/index.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/index.js +1 -1
- package/es/utils/index.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,l)=>new Promise((a,o)=>{var c=p=>{try{u(l.next(p))}catch(h){o(h)}},P=p=>{try{u(l.throw(p))}catch(h){o(h)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,P);u((l=l.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,l,a,o)=>{const{x:c,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:c,y:P,z:u},id:e.id},h=a?__spreadValues(__spreadValues({},a),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,l,a,o,c)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),u=0,p=1,h={};if(l){const L=l.getSensesPointZAxisInPolygon(P,void 0,c);c&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),u=(L.maxZ+L.minZ)/2,p=L.maxZ-L.minZ,h={count:L.zCount}}const[y,w,T]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([y,T]),I=lbAnnotation.MathUtils.getLineLength(y,w),D=lbAnnotation.MathUtils.getLineLength(w,T),R=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const V={center:{x:U.x,y:U.y,z:u},width:c?D+INTELLIGENT_FIT_MARGIN:D,height:c?I+INTELLIGENT_FIT_MARGIN:I,depth:p,rotation:R,id:e.id},_=__spreadValues(a?__spreadValues(__spreadValues({},a),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,l)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},l),{center:{x:l.center.x-a.x,y:l.center.y,z:l.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,l,a)=>{const[o,c,P]=e.pointList,[u,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),w=lbAnnotation.MathUtils.getLineCenterPoint([u,h]),U={x:{x:y.x-w.x,y:y.y-w.y}.x,y:0,z:y.y-w.y},I=lbAnnotation.MathUtils.getLineLength(o,c),D=lbAnnotation.MathUtils.getLineLength(u,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(c,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:L}=a.getNewBoxBySideUpdate(U,k,R,l);return L},backViewPoint2PointCloud=(e,t,l)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},l),{center:{x:l.center.x,y:l.center.y-a.x,z:l.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,l,a)=>{const[o,c,P]=e.pointList,[u,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),w=lbAnnotation.MathUtils.getLineCenterPoint([u,h]),U={x:{x:y.x-w.x,y:y.y-w.y}.x,y:0,z:y.y-w.y},I=lbAnnotation.MathUtils.getLineLength(o,c),D=lbAnnotation.MathUtils.getLineLength(u,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(c,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:L}=a.getNewBoxByBackUpdate(U,k,R,l);return L},syncSideViewByPoint=(e,t,l,a,o)=>{var c;if(!l)return;const{toolInstance:P,pointCloudInstance:u}=l;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(p);const{point2d:h,zoom:y}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=y,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,l,a)=>{if(!l)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=l;c.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,l,a,o)=>{var c;if(!l)return;const{toolInstance:P,pointCloudInstance:u}=l;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(p);const{point2d:h,zoom:y}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=y,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,l,a)=>{if(!l)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=l;c.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,l,a)=>{if(!l||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=l,{point2d:P}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},synchronizeTopView=(e,t,l,a)=>{var o,c;if(!l||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:u}=l,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(w=>w.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:l,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:P,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:w,setHighlight2DDataList:T,cuboidBoxIn2DView:U,imageSizes:I}=e,{addHistory:D,initHistory:R,pushHistoryUnderUpdatePolygon:V}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{getPointCloudSphereByID:k,updatePointCloudSphere:L,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(i=>{const{stepList:n,step:d,imgList:s,imgIndex:r}=i.annotation;return{currentData:s[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,n).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=i=>{if(!tt.current){const{mappingImgList:n=[]}=j,d=n.map(s=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:s,imageSizes:I}));Object.assign(i,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),X=S==null?void 0:S.info;if(!t||!l||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},nt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:i,size:n,zoom:d,trackConfigurable:s})=>{var r;const g={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};s===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(i,n,G,void 0,g);u(i.id);const C=P(f);q(PointCloudView.Top,i,f,d,C,m),D({newSphereParams:f})},lt=({polygon:i,size:n,imgList:d,trackConfigurable:s,zoom:r,intelligentFit:g})=>{var f,C,v;const b={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};s===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const z=t==null?void 0:t.toolInstance,B=__spreadValues({},i);let{boxParams:x,newPointList:O}=topViewPolygon2PointCloud(B,n,G,void 0,b,g);x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[x],stepConfig:m,action:"viewUpdateBox"}))[0],g&&(O==null?void 0:O.length)&&(B.pointList=O);const Q=w.includes(B.attribute);W(x);const E=c(x),F=(C=e==null?void 0:e.polygonList)!=null?C:[];x.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((m==null?void 0:m.secondaryAttributeConfigurable)?(v=m==null?void 0:m.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),Q?u([]):(u(x.id),z.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:x,zoom:r,newPointCloudBoxList:E}),g&&synchronizeTopView(x,B,t,o)),D({newBoxParams:x})},rt=i=>{const{boxID:n,imageName:d,width:s,height:r,x:g,y:f}=i,C=h.find(x=>x.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(x=>x.imageName===d))return;const b=C.rects.map(x=>x.imageName===d?__spreadProps(__spreadValues({},x),{width:s,height:r,x:g,y:f}):x),z=__spreadProps(__spreadValues({},C),{rects:b}),B=h.map(x=>x.id===n?z:x);return t==null||t.updatePolygonList(B!=null?B:[]),B},dt=i=>{const{boxID:n,imageName:d}=i,s=h.find(C=>C.id===n);if(!(s==null?void 0:s.rects))return;const r=s.rects.filter(C=>C.imageName!==d),g=__spreadProps(__spreadValues({},s),{rects:r}),f=h.map(C=>C.id===n?g:C);return t==null||t.updatePolygonList(f!=null?f:[]),f},at=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:s})=>{var r;const g=t==null?void 0:t.toolInstance;if(!(p.length===0||!g)){if(i||(S==null?void 0:S.info)){const f=i!=null?i:S==null?void 0:S.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(p[0]);const C=g.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:C,boxParams:f,newPointCloudBoxList:n});return}}if((d||N)&&p.length===1){const f=d!=null?d:N;g.setSelectedID(p[0]);const C=g.selectedPoint;f&&q(PointCloudView.Top,C,f,void 0,s,m)}}},Y=(i,n,d)=>{if(X){let s,r;switch(d){case PointCloudView.Back:s=backViewPolygon2PointCloud;break;case PointCloudView.Side:s=sideViewPolygon2PointCloud;break;default:s=sideViewPolygon2PointCloud;break}if(r=s(i,n,X,l.pointCloudInstance),o){const{count:b}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:m,action:"viewUpdateBox"}))[0],C=r.valid!==f.valid;r=f;const v=ot(r);return r=v.find(b=>b.id===r.id),M({omitView:C?void 0:d,polygon:i,boxParams:r,newPointCloudBoxList:v}),v}},K=(i,n,d)=>{if(N){let s,r;switch(d){case PointCloudView.Back:s=backViewPoint2PointCloud;break;case PointCloudView.Side:s=sideViewPoint2PointCloud;break;default:s=sideViewPoint2PointCloud;break}r=s(i,n,N);const g=L(r);return q(d,i,r,void 0,g,m),g}},ct=(i,n)=>{K(i,n,PointCloudView.Side)},ut=(i,n)=>{K(i,n,PointCloudView.Back)},pt=(i,n)=>{Y(i,n,PointCloudView.Side)},Pt=(i,n)=>{Y(i,n,PointCloudView.Back)},gt=(i,n)=>{const d=k(i.id),s=topViewPoint2PointCloud(i,n,G,d),r=L(s);q(PointCloudView.Top,i,s,void 0,r,m)},Ct=(i,n)=>{if(_){const s=__spreadValues({},i[0].newPolygon);s.pointList=s.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,n)),V(s);return}let d=i.map(({newPolygon:s})=>{const r=et(s.id),{boxParams:g}=topViewPolygon2PointCloud(s,n,t.pointCloudInstance,r);return g});if(d=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:m,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=i[0],r=Z(d);M({polygon:s,boxParams:d[0],newPointCloudBoxList:r})}else{const s=Z(d);s&&e.syncAllViewPointCloudColor(s)}},ft=i=>{var n,d,s,r,g;if(S){const f=Number(i.widthDefault),C=Number(i.depthDefault),v=Number(i.heightDefault),b=S==null?void 0:S.info.trackID,B=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(H=>(H==null?void 0:H.trackID)===b),x={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(g=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:g.height},O=B.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,x)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,f),Q=J[0],E=J[2],F=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:F.x,y:F.y,z:ht+C/2},width:f,height:v,depth:C,valid:!0}),vt=Z([$]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:$,newPointCloudBoxList:vt})}},q=(i,n,d,s,r,g)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,n,l,f,g)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(d,n,a,f,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,n,t,o)}};Object.keys(C).forEach(v=>{v!==i&&C[v]()}),s&&(o==null||o.updateCameraZoom(s)),nt(d)}),M=i=>__async(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:s,zoom:r,newPointCloudBoxList:g}=i,f=j==null?void 0:j.url;g&&(yield e.syncAllViewPointCloudColor(g));const C={[PointCloudView.Side]:()=>{synchronizeSideView(s,d,l,f)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(s,d,a,f)},[PointCloudView.Top]:()=>{synchronizeTopView(s,d,t,o)}};Object.keys(C).forEach(v=>{v!==n&&C[v]()}),r&&(o==null||o.updateCameraZoom(r)),it(s)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:at,topViewUpdatePoint:gt,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:Ct,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(n=j){var d,s,r,g,f,C;if(!(n==null?void 0:n.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(n.url,(d=m==null?void 0:m.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],b=[],z=[],B=[];o.updateTopCamera();const x=(r=(s=index.jsonParser(n.result))==null?void 0:s.valid)!=null?r:!0;if(e.setPointCloudValid(x),(g=e.sideViewInstance)==null||g.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(m==null?void 0:m.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(n.url,m,v);const O=index.jsonParser(n.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(O),e.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=m==null?void 0:m.radius)!=null?C:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(v,[])}R({pointCloudBoxList:v,polygonList:z,lineList:b,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ft,generateRects:W,update2DViewRect:rt,remove2DViewRect:dt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((d,o)=>{var u=p=>{try{c(s.next(p))}catch(h){o(h)}},P=p=>{try{c(s.throw(p))}catch(h){o(h)}},c=p=>p.done?d(p.value):Promise.resolve(p.value).then(u,P);c((s=s.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,s,d,o)=>{const{x:u,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:u,y:P,z:c},id:e.id},h=d?__spreadValues(__spreadValues({},d),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,s,d,o,u)=>{let P=e.pointList.map(m=>lbUtils.PointCloudUtils.transferCanvas2World(m,t)),c=0,p=1,h={};if(s){const m=s.getSensesPointZAxisInPolygon(P,void 0,u);u&&m.fittedCoordinates.length>0&&(P=m.fittedCoordinates),c=(m.maxZ+m.minZ)/2,p=m.maxZ-m.minZ,h={count:m.zCount}}const[y,b,T]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([y,T]),I=lbAnnotation.MathUtils.getLineLength(y,b),D=lbAnnotation.MathUtils.getLineLength(b,T),R=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,p=d.depth);const V={center:{x:U.x,y:U.y,z:c},width:u?D+INTELLIGENT_FIT_MARGIN:D,height:u?I+INTELLIGENT_FIT_MARGIN:I,depth:p,rotation:R,id:e.id},_=__spreadValues(d?__spreadValues(__spreadValues({},d),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(m=>lbUtils.PointCloudUtils.transferWorld2Canvas(m,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,s)=>{const d={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-d.x,y:s.center.y,z:s.center.z-d.y}})},sideViewPolygon2PointCloud=(e,t,s,d)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},I=lbAnnotation.MathUtils.getLineLength(o,u),D=lbAnnotation.MathUtils.getLineLength(c,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:m}=d.getNewBoxBySideUpdate(U,k,R,s);return m},backViewPoint2PointCloud=(e,t,s)=>{const d={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-d.x,z:s.center.z-d.y}})},backViewPolygon2PointCloud=(e,t,s,d)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},I=lbAnnotation.MathUtils.getLineLength(o,u),D=lbAnnotation.MathUtils.getLineLength(c,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:m}=d.getNewBoxByBackUpdate(U,k,R,s);return m},syncSideViewByPoint=(e,t,s,d,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(d,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,s,d)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(d,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxSidePolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,s,d,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(d,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,s,d)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(d,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxBackPolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,s,d)=>{if(!s||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),d.render();const{toolInstance:o,pointCloudInstance:u}=s,{point2d:P}=u.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,s,d)=>{var o,u;if(!s||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=s,{polygon2d:p}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(b=>b.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(u=e.valid)!=null?u:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:d,mainViewInstance:o,addPointCloudBox:u,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:U,imageSizes:I}=e,{addHistory:D,initHistory:R,pushHistoryUnderUpdatePolygon:V}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{getPointCloudSphereByID:k,updatePointCloudSphere:m,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:L}=ctx.useSelector(n=>{const{stepList:i,step:a,imgList:l,imgIndex:r}=n.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,i).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=n=>{const{enableAutoMap2DRect:i=!1}=L;if(!tt.current||i){const{mappingImgList:a=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:n,mappingImgList:a,imageSizes:I})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),X=S==null?void 0:S.info;if(!t||!s||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},nt=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:n,size:i,zoom:a,trackConfigurable:l})=>{var r;const C={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(n,i,G,void 0,C);c(n.id);const g=P(f);q(PointCloudView.Top,n,f,a,g,L),D({newSphereParams:f})},lt=({polygon:n,size:i,imgList:a,trackConfigurable:l,zoom:r,intelligentFit:C})=>{var f,g,v;const w={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};l===!0&&Object.assign(w,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const z=t==null?void 0:t.toolInstance,B=__spreadValues({},n);let{boxParams:x,newPointList:O}=topViewPolygon2PointCloud(B,i,G,void 0,w,C);x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[x],stepConfig:L,action:"viewUpdateBox"}))[0],C&&(O==null?void 0:O.length)&&(B.pointList=O);const Q=b.includes(B.attribute);W(x);const E=u(x),F=(g=e==null?void 0:e.polygonList)!=null?g:[];x.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((L==null?void 0:L.secondaryAttributeConfigurable)?(v=L==null?void 0:L.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),Q?c([]):(c(x.id),z.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:x,zoom:r,newPointCloudBoxList:E}),C&&synchronizeTopView(x,B,t,o)),D({newBoxParams:x})},rt=n=>{const{boxID:i,imageName:a,width:l,height:r,x:C,y:f}=n,g=h.find(x=>x.id===i);if(!(g==null?void 0:g.rects)||!g.rects.find(x=>x.imageName===a))return;const w=g.rects.map(x=>x.imageName===a?__spreadProps(__spreadValues({},x),{width:l,height:r,x:C,y:f}):x),z=__spreadProps(__spreadValues({},g),{rects:w}),B=h.map(x=>x.id===i?z:x);return t==null||t.updatePolygonList(B!=null?B:[]),B},at=n=>{const{boxID:i,imageName:a}=n,l=h.find(g=>g.id===i);if(!(l==null?void 0:l.rects))return;const r=l.rects.filter(g=>g.imageName!==a),C=__spreadProps(__spreadValues({},l),{rects:r}),f=h.map(g=>g.id===i?C:g);return t==null||t.updatePolygonList(f!=null?f:[]),f},dt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:a,newSphereList:l})=>{var r;const C=t==null?void 0:t.toolInstance;if(!(p.length===0||!C)){if(n||(S==null?void 0:S.info)){const f=n!=null?n:S==null?void 0:S.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(p[0]);const g=C.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:g,boxParams:f,newPointCloudBoxList:i});return}}if((a||N)&&p.length===1){const f=a!=null?a:N;C.setSelectedID(p[0]);const g=C.selectedPoint;f&&q(PointCloudView.Top,g,f,void 0,l,L)}}},Y=(n,i,a)=>{if(X){let l,r;switch(a){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(n,i,X,s.pointCloudInstance),o){const{count:w}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:w})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],g=r.valid!==f.valid;r=f;const v=ot(r);return r=v.find(w=>w.id===r.id),M({omitView:g?void 0:a,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},K=(n,i,a)=>{if(N){let l,r;switch(a){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(n,i,N);const C=m(r);return q(a,n,r,void 0,C,L),C}},ut=(n,i)=>{K(n,i,PointCloudView.Side)},ct=(n,i)=>{K(n,i,PointCloudView.Back)},pt=(n,i)=>{Y(n,i,PointCloudView.Side)},Pt=(n,i)=>{Y(n,i,PointCloudView.Back)},Ct=(n,i)=>{const a=k(n.id),l=topViewPoint2PointCloud(n,i,G,a),r=m(l);q(PointCloudView.Top,n,l,void 0,r,L)},gt=(n,i)=>{if(_){const l=__spreadValues({},n[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,i)),V(l);return}let a=n.map(({newPolygon:l})=>{const r=et(l.id),{boxParams:C}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,r);return C});if(a=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:L,action:"viewUpdateBox"})),a.length===1){const{newPolygon:l}=n[0],r=Z(a);M({polygon:l,boxParams:a[0],newPointCloudBoxList:r})}else{const l=Z(a);l&&e.syncAllViewPointCloudColor(l)}},ft=n=>{var i,a,l,r,C;if(S){const f=Number(n.widthDefault),g=Number(n.depthDefault),v=Number(n.heightDefault),w=S==null?void 0:S.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(H=>(H==null?void 0:H.trackID)===w),x={width:(l=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:l.width,height:(C=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:C.height},O=B.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,x)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,f),Q=J[0],E=J[2],F=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:F.x,y:F.y,z:ht+g/2},width:f,height:v,depth:g,valid:!0}),vt=Z([$]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:$,newPointCloudBoxList:vt})}},q=(n,i,a,l,r,C)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,g={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,i,s,f,C)},[PointCloudView.Back]:()=>{d&&syncBackViewByPoint(a,i,d,f,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,i,t,o)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),l&&(o==null||o.updateCameraZoom(l)),nt(a)}),M=n=>__async(void 0,null,function*(){const{omitView:i,polygon:a,boxParams:l,zoom:r,newPointCloudBoxList:C}=n,f=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const g={[PointCloudView.Side]:()=>{synchronizeSideView(l,a,s,f)},[PointCloudView.Back]:()=>{d&&synchronizeBackView(l,a,d,f)},[PointCloudView.Top]:()=>{synchronizeTopView(l,a,t,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),r&&(o==null||o.updateCameraZoom(r)),it(l)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:dt,topViewUpdatePoint:Ct,sideViewUpdatePoint:ut,backViewUpdatePoint:ct,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(i=j){var a,l,r,C,f,g;if(!(i==null?void 0:i.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(i.url,(a=L==null?void 0:L.radius)!=null?a:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],w=[],z=[],B=[];o.updateTopCamera();const x=(r=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?r:!0;if(e.setPointCloudValid(x),(C=e.sideViewInstance)==null||C.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),i.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(L==null?void 0:L.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,L,v);const O=index.jsonParser(i.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,i.result=JSON.stringify(O),e.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(g=L==null?void 0:L.radius)!=null?g:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(v,[])}R({pointCloudBoxList:v,polygonList:z,lineList:w,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ft,generateRects:W,update2DViewRect:rt,remove2DViewRect:at}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$1=require("./components/AnnotationView/index.js"),pointCloudAnnotationView=require("./components/AnnotationView/pointCloudAnnotationView.js"),index$2=require("./components/LLMToolView/questionView/index.js"),index$3=require("./components/NLPToolView/textContent/index.js"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),reactI18next=require("react-i18next"),reactRedux=require("react-redux"),App=require("./App.js"),configureStore=require("./configureStore.js"),actionCreators=require("./store/annotation/actionCreators.js"),TagToolInstanceAdaptorI18nProvider=require("./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js"),PointCloudContext=require("./components/pointCloudView/PointCloudContext.js"),ctx=require("./store/ctx.js"),index$5=require("./components/predictTracking/predictTrackingIcon/index.js"),index$4=require("./components/LLMToolView/index.js"),index$6=require("./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js"),index$7=require("./components/measureCanvas/index.js"),index$8=require("./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js"),index$9=require("./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js"),index$a=require("./components/audioPlayer/index.js"),index$b=require("./constant/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$1=require("./components/AnnotationView/index.js"),pointCloudAnnotationView=require("./components/AnnotationView/pointCloudAnnotationView.js"),index$2=require("./components/LLMToolView/questionView/index.js"),index$3=require("./components/NLPToolView/textContent/index.js"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),reactI18next=require("react-i18next"),reactRedux=require("react-redux"),App=require("./App.js"),configureStore=require("./configureStore.js"),actionCreators=require("./store/annotation/actionCreators.js"),TagToolInstanceAdaptorI18nProvider=require("./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js"),PointCloudContext=require("./components/pointCloudView/PointCloudContext.js"),ctx=require("./store/ctx.js"),index$5=require("./components/predictTracking/predictTrackingIcon/index.js"),index$4=require("./components/LLMToolView/index.js"),index$6=require("./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js"),index$7=require("./components/measureCanvas/index.js"),index$8=require("./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js"),index$9=require("./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js"),index$a=require("./components/audioPlayer/index.js"),index$b=require("./utils/index.js"),index$c=require("./constant/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const store=configureStore(),OutputApp=(e,t)=>{const[r,i]=React.useState();return React.useImperativeHandle(t,()=>({toolInstance:r,annotationEngine:store.getState().annotation.annotationEngine,pageBackwardActions:()=>store.dispatch(actionCreators.PageBackward()),pageForwardActions:()=>store.dispatch(actionCreators.PageForward()),pageJump:o=>{const n=~~o-1;store.dispatch(actionCreators.PageJump(n))},hello:()=>alert("hello labelBee!!!")}),[r]),React__default.default.createElement(reactRedux.Provider,{store,context:ctx.LabelBeeContext},React__default.default.createElement(reactI18next.I18nextProvider,{i18n:lbUtils.i18n},React__default.default.createElement(PointCloudContext.PointCloudProvider,null,React__default.default.createElement(App,__spreadProps(__spreadValues({},e),{setToolInstance:o=>{var n;i(o),(n=e.onLoad)==null||n.call(e,{toolInstance:o})}})))))};var index=React__default.default.forwardRef(OutputApp);exports.AnnotationView=index$1,exports.PointCloudAnnotationView=pointCloudAnnotationView,exports.QuestionView=index$2.default,exports.TextContent=index$3,Object.defineProperty(exports,"i18n",{enumerable:!0,get:function(){return lbUtils.i18n}}),exports.VideoTagTool=TagToolInstanceAdaptorI18nProvider.VideoTagTool,exports.PredictTracking=index$5,exports.LLMToolView=index$4,exports.SwitchCuboidBoxIn2DView=index$6,exports.MeasureCanvas=index$7,exports.AnnotatedBox=index$8,exports.FindTrackIDIndex=index$9.FindTrackIDIndexInCheckMode,exports.AudioPlayer=index$a.WrapAudioPlayer,exports.generatePointCloudBoxRects=index$b.generatePointCloudBoxRects,Object.defineProperty(exports,"EDataFormatType",{enumerable:!0,get:function(){return index$c.EDataFormatType}}),Object.defineProperty(exports,"ELLMDataType",{enumerable:!0,get:function(){return index$c.ELLMDataType}}),Object.defineProperty(exports,"EStepType",{enumerable:!0,get:function(){return index$c.EStepType}}),Object.defineProperty(exports,"ESubmitType",{enumerable:!0,get:function(){return index$c.ESubmitType}}),exports.componentCls=index$c.componentCls,exports.prefix=index$c.prefix,exports.default=index,exports.store=store;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,11 +14,12 @@ import MeasureCanvas from './components/measureCanvas';
|
|
|
14
14
|
import AnnotatedBox from './views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox';
|
|
15
15
|
import { FindTrackIDIndexInCheckMode as FindTrackIDIndex } from './views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex';
|
|
16
16
|
import { WrapAudioPlayer as AudioPlayer } from './components/audioPlayer';
|
|
17
|
+
import { generatePointCloudBoxRects } from './utils';
|
|
17
18
|
export declare const store: import("redux").Store<{}, import("redux").Action<any>> & {
|
|
18
19
|
dispatch: unknown;
|
|
19
20
|
};
|
|
20
21
|
declare const _default: React.ForwardRefExoticComponent<AppProps & React.RefAttributes<unknown>>;
|
|
21
22
|
export default _default;
|
|
22
|
-
export { AnnotationView, PointCloudAnnotationView, QuestionView, TextContent, LLMToolView, i18n, VideoTagTool, PredictTracking, SwitchCuboidBoxIn2DView, MeasureCanvas, AnnotatedBox, FindTrackIDIndex, AudioPlayer, };
|
|
23
|
+
export { AnnotationView, PointCloudAnnotationView, QuestionView, TextContent, LLMToolView, i18n, VideoTagTool, PredictTracking, SwitchCuboidBoxIn2DView, MeasureCanvas, AnnotatedBox, FindTrackIDIndex, AudioPlayer, generatePointCloudBoxRects, };
|
|
23
24
|
export * from './constant';
|
|
24
25
|
export * from './typeTem';
|
|
@@ -28,4 +28,25 @@ export declare const getRectPointCloudBox: (params: IGetRectPointCloudBoxParams)
|
|
|
28
28
|
width: number;
|
|
29
29
|
height: number;
|
|
30
30
|
} | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Updates the given point cloud box with rectangles derived from the mapping image list and image sizes.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} params - The parameters for the function.
|
|
35
|
+
* @param {IPointCloudBox} params.pointCloudBox - The point cloud box object to be updated.
|
|
36
|
+
* @param {IMappingImg[]} params.mappingImgList - The list of mapping images to process.
|
|
37
|
+
* @param {Object.<string, ISize>} params.imageSizes - An object containing image sizes keyed by image paths.
|
|
38
|
+
*
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*
|
|
41
|
+
* @description This function processes a list of mapping images to generate rectangles for the provided point cloud box.
|
|
42
|
+
* It filters out undefined rectangles and updates the point cloud box with the valid rectangles. Note that this function
|
|
43
|
+
* modifies the `pointCloudBox` parameter by adding a `rects` property.
|
|
44
|
+
*/
|
|
45
|
+
export declare const generatePointCloudBoxRects: (params: {
|
|
46
|
+
pointCloudBox: IPointCloudBox;
|
|
47
|
+
mappingImgList: IMappingImg[];
|
|
48
|
+
imageSizes: {
|
|
49
|
+
[key: string]: ISize;
|
|
50
|
+
};
|
|
51
|
+
}) => void;
|
|
31
52
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const jsonParser=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):___default.default.isObject(e)?e:t}catch(n){return t}},classnames=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(___default.default.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},getBoundingRect=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},isBoundingRectInImage=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),s=Math.min(t.y+t.height,n.y+n.height),a=i-r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const jsonParser=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):___default.default.isObject(e)?e:t}catch(n){return t}},classnames=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(___default.default.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},getBoundingRect=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},isBoundingRectInImage=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),s=Math.min(t.y+t.height,n.y+n.height),a=i-r,c=s-o;return a>=0&&c>=0?{x:r,y:o,width:a,height:c}:null};return(t,n,r)=>{if(r[n]){const o=r[n].width,i=r[n].height;return e(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),getRectPointCloudBox=e=>{var t;const{pointCloudBox:n,mappingData:r,imageSizes:o}=e,{transferViewData:i}=(t=lbAnnotation.pointCloudLidar2image(n,r.calib))!=null?t:{};if(!i)return;const s=i.reduce((u,p)=>p.type==="line"?[...u,...p.pointList]:u,[]),a=__spreadProps(__spreadValues({},getBoundingRect(s)),{imageName:r.path});if(isBoundingRectInImage(a,r.path,o))return a},generatePointCloudBoxRects=e=>{const{pointCloudBox:t,mappingImgList:n,imageSizes:r}=e,i=n.map(s=>getRectPointCloudBox({pointCloudBox:t,mappingData:s,imageSizes:r})).filter(s=>s!==void 0);i.length>0&&Object.assign(t,{rects:i})};exports.classnames=classnames,exports.generatePointCloudBoxRects=generatePointCloudBoxRects,exports.getBoundingRect=getBoundingRect,exports.getRectPointCloudBox=getRectPointCloudBox,exports.isBoundingRectInImage=isBoundingRectInImage,exports.jsonParser=jsonParser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as it,TagUtils as Gt,MathUtils as w,getCuboidFromPointCloudBox as Jt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Qt,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Kt}from"./useSingleBox.js";import{useSphere as $t}from"./useSphere.js";import{useSelector as to,useDispatch as oo}from"../../../store/ctx.js";import eo from"../../../utils/StepUtils.js";import{jsonParser as st,getRectPointCloudBox as no}from"../../../utils/index.js";import{PreDataProcess as rt,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))uo.call(t,r)&&ht(e,r,t[r]);if(mt)for(var r of mt(t))po.call(t,r)&&ht(e,r,t[r]);return e},O=(e,t)=>ao(e,co(t)),lt=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(m){o(m)}},g=p=>{try{u(r.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((r=r.apply(e,t)).next())});const q=5,K=90,xt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,t,r,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=Xt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):O(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},at=(e,t,r,a,o,c)=>{let g=e.pointList.map(B=>V.transferCanvas2World(B,t)),u=0,p=1,m={};if(r){const B=r.getSensesPointZAxisInPolygon(g,void 0,c);c&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,p=B.maxZ-B.minZ,m={count:B.zCount}}const[v,D,H]=g,A=w.getLineCenterPoint([v,H]),k=w.getLineLength(v,D),R=w.getLineLength(D,H),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:A.x,y:A.y,z:u},width:c?R+xt:R,height:c?k+xt:k,depth:p,rotation:j,id:e.id},T=L(a?L(L({},a),U):O(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(B=>V.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:N}},vt=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},Lt=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T,{newBoxParams:B}=a.getNewBoxBySideUpdate(A,N,j,r);return B},go=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},fo=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T;let{newBoxParams:B}=a.getNewBoxByBackUpdate(A,N,j,r);return B},yt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ct=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:H,cuboidBoxIn2DView:A,imageSizes:k}=e,{addHistory:R,initHistory:j,pushHistoryUnderUpdatePolygon:U}=io(),{selectedPolygon:T}=so(),{getPointCloudSphereByID:N,updatePointCloudSphere:B,selectedSphere:J}=$t(),{currentData:W,config:b}=to(n=>{const{stepList:i,step:d,imgList:s,imgIndex:l}=n.annotation;return{currentData:s[l],config:st(eo.getCurrentStepInfo(d,i).config)}}),E=oo(),Dt=ro(A),$=n=>{if(!Dt.current){const{mappingImgList:i=[]}=W,d=i.map(s=>no({pointCloudBox:n,mappingData:s,imageSizes:k}));Object.assign(n,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=Kt({generateRects:$}),ut=_==null?void 0:_.info;if(!t||!r||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:n,size:i,zoom:d,trackConfigurable:s})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=dt(n,i,ot,void 0,f);u(n.id);const C=g(P);Q(y.Top,n,P,d,C,b),R({newSphereParams:P})},At=({polygon:n,size:i,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:f})=>{var P,C,h;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};s===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const F=t==null?void 0:t.toolInstance,I=L({},n);let{boxParams:x,newPointList:z}=at(I,i,ot,void 0,S,f);x=E(rt({tool:it.PointCloud,dataList:[x],stepConfig:b,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(x);const M=c(x),X=(C=e==null?void 0:e.polygonList)!=null?C:[];x.subAttribute=Gt.getDefaultResultByConfig((b==null?void 0:b.secondaryAttributeConfigurable)?(h=b==null?void 0:b.inputList)!=null?h:[]:[]),t==null||t.updatePolygonList(M!=null?M:[],X),nt?u([]):(u(x.id),F.selection.setSelectedIDs(I.id),Z({omitView:y.Top,polygon:I,boxParams:x,zoom:l,newPointCloudBoxList:M}),f&&ct(x,I,t,o)),R({newBoxParams:x})},kt=n=>{const{boxID:i,imageName:d,width:s,height:l,x:f,y:P}=n,C=m.find(x=>x.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(x=>x.imageName===d))return;const S=C.rects.map(x=>x.imageName===d?O(L({},x),{width:s,height:l,x:f,y:P}):x),F=O(L({},C),{rects:S}),I=m.map(x=>x.id===i?F:x);return t==null||t.updatePolygonList(I!=null?I:[]),I},Ut=n=>{const{boxID:i,imageName:d}=n,s=m.find(C=>C.id===i);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(C=>C.imageName!==d),f=O(L({},s),{rects:l}),P=m.map(C=>C.id===i?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},Tt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:s})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(n||(_==null?void 0:_.info)){const P=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){Z({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:i});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,s,b)}}},pt=(n,i,d)=>{if(ut){let s,l;switch(d){case y.Back:s=fo;break;case y.Side:s=Lt;break;default:s=Lt;break}if(l=s(n,i,ut,r.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Jt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:S})}const P=E(rt({tool:it.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const h=St(l);return l=h.find(S=>S.id===l.id),Z({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:h}),h}},gt=(n,i,d)=>{if(J){let s,l;switch(d){case y.Back:s=go;break;case y.Side:s=vt;break;default:s=vt;break}l=s(n,i,J);const f=B(l);return Q(d,n,l,void 0,f,b),f}},zt=(n,i)=>{gt(n,i,y.Side)},jt=(n,i)=>{gt(n,i,y.Back)},Nt=(n,i)=>{pt(n,i,y.Side)},Et=(n,i)=>{pt(n,i,y.Back)},Ft=(n,i)=>{const d=N(n.id),s=dt(n,i,ot,d),l=B(s);Q(y.Top,n,s,void 0,l,b)},Ht=(n,i)=>{if(T){const s=L({},n[0].newPolygon);s.pointList=s.pointList.map(l=>V.transferCanvas2World(l,i)),U(s);return}let d=n.map(({newPolygon:s})=>{const l=_t(s.id),{boxParams:f}=at(s,i,t.pointCloudInstance,l);return f});if(d=E(rt({tool:it.PointCloud,dataList:d,stepConfig:b,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=n[0],l=tt(d);Z({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=tt(d);s&&e.syncAllViewPointCloudColor(s)}},Wt=n=>{var i,d,s,l,f;if(_){const P=Number(n.widthDefault),C=Number(n.depthDefault),h=Number(n.heightDefault),S=_==null?void 0:_.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),x={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,x)),et=w.getModifiedRectangleCoordinates(z,h,P),nt=et[0],M=et[2],X=w.getLineCenterPoint([nt,M]),Zt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:X.x,y:X.y,z:Zt+C/2},width:P,height:h,depth:C,valid:!0}),Mt=tt([ft]);Z({omitView:y["3D"],polygon:I,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(n,i,d,s,l,f)=>lt(void 0,null,function*(){const P=W==null?void 0:W.url,C={[y.Side]:()=>{yt(d,i,r,P,f)},[y.Back]:()=>{a&&bt(d,i,a,P,f)},[y.Top]:()=>{It(d,i,t,o)}};Object.keys(C).forEach(h=>{h!==n&&C[h]()}),s&&(o==null||o.updateCameraZoom(s)),Ot(d)}),Z=n=>lt(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:f}=n,P=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[y.Side]:()=>{Bt(s,d,r,P)},[y.Back]:()=>{a&&wt(s,d,a,P)},[y.Top]:()=>{ct(s,d,t,o)}};Object.keys(C).forEach(h=>{h!==i&&C[h]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(s)});return{topViewAddSphere:Rt,topViewAddBox:At,topViewSelectedChanged:Tt,topViewUpdatePoint:Ft,sideViewUpdatePoint:zt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>lt(void 0,[...n],function*(i=W){var d,s,l,f,P,C;if(!(i==null?void 0:i.url)||!o)return;H([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(i.url,(d=b==null?void 0:b.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],S=[],F=[],I=[];o.updateTopCamera();const x=(l=(s=st(i.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(x),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),i.result){if(h=V.getBoxParamsFromResultList(i.result),(h==null?void 0:h.length)>0&&i.isPreResult&&(b==null?void 0:b.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(i.url,b,h);const z=st(i.result);z[Qt].result=h,i.result=JSON.stringify(z),e.setPointCloudResult(h)}F=V.getPolygonListFromResultList(i.result),S=V.getLineListFromResultList(i.result),I=V.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=b==null?void 0:b.radius)!=null?C:K}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(h,[])}j({pointCloudBoxList:h,polygonList:F,lineList:S,pointCloudSphereList:I}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:kt,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,Co as usePointCloudViews};
|
|
1
|
+
import{EPointCloudName as it,TagUtils as Gt,MathUtils as w,getCuboidFromPointCloudBox as Jt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Qt,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Kt}from"./useSingleBox.js";import{useSphere as $t}from"./useSphere.js";import{useSelector as to,useDispatch as oo}from"../../../store/ctx.js";import eo from"../../../utils/StepUtils.js";import{jsonParser as st,generatePointCloudBoxRects as no}from"../../../utils/index.js";import{PreDataProcess as rt,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,xt=(e,t,s)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))uo.call(t,s)&&xt(e,s,t[s]);if(mt)for(var s of mt(t))po.call(t,s)&&xt(e,s,t[s]);return e},O=(e,t)=>ao(e,co(t)),lt=(e,t,s)=>new Promise((a,o)=>{var c=p=>{try{u(s.next(p))}catch(m){o(m)}},g=p=>{try{u(s.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((s=s.apply(e,t)).next())});const q=5,K=90,ht=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,t,s,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=Xt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):O(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},at=(e,t,s,a,o,c)=>{let g=e.pointList.map(b=>V.transferCanvas2World(b,t)),u=0,p=1,m={};if(s){const b=s.getSensesPointZAxisInPolygon(g,void 0,c);c&&b.fittedCoordinates.length>0&&(g=b.fittedCoordinates),u=(b.maxZ+b.minZ)/2,p=b.maxZ-b.minZ,m={count:b.zCount}}const[v,D,H]=g,A=w.getLineCenterPoint([v,H]),k=w.getLineLength(v,D),R=w.getLineLength(D,H),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:A.x,y:A.y,z:u},width:c?R+ht:R,height:c?k+ht:k,depth:p,rotation:j,id:e.id},T=L(a?L(L({},a),U):O(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(b=>V.transferWorld2Canvas(b,t));return{boxParams:T,newPointList:N}},vt=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},Lt=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T,{newBoxParams:b}=a.getNewBoxBySideUpdate(A,N,j,s);return b},go=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},fo=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T;let{newBoxParams:b}=a.getNewBoxByBackUpdate(A,N,j,s);return b},yt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=s,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ct=(e,t,s,a)=>{var o,c;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=s,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:H,cuboidBoxIn2DView:A,imageSizes:k}=e,{addHistory:R,initHistory:j,pushHistoryUnderUpdatePolygon:U}=io(),{selectedPolygon:T}=so(),{getPointCloudSphereByID:N,updatePointCloudSphere:b,selectedSphere:J}=$t(),{currentData:W,config:B}=to(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:st(eo.getCurrentStepInfo(d,n).config)}}),E=oo(),Dt=ro(A),$=i=>{const{enableAutoMap2DRect:n=!1}=B;if(!Dt.current||n){const{mappingImgList:d=[]}=W;no({pointCloudBox:i,mappingImgList:d,imageSizes:k})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=Kt({generateRects:$}),ut=_==null?void 0:_.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},Ot=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:i,size:n,zoom:d,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=dt(i,n,ot,void 0,f);u(i.id);const C=g(P);Q(y.Top,i,P,d,C,B),R({newSphereParams:P})},At=({polygon:i,size:n,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,C,x;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const F=t==null?void 0:t.toolInstance,I=L({},i);let{boxParams:h,newPointList:z}=at(I,n,ot,void 0,S,f);h=E(rt({tool:it.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(h);const M=c(h),X=(C=e==null?void 0:e.polygonList)!=null?C:[];h.subAttribute=Gt.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(x=B==null?void 0:B.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(M!=null?M:[],X),nt?u([]):(u(h.id),F.selection.setSelectedIDs(I.id),Z({omitView:y.Top,polygon:I,boxParams:h,zoom:l,newPointCloudBoxList:M}),f&&ct(h,I,t,o)),R({newBoxParams:h})},kt=i=>{const{boxID:n,imageName:d,width:r,height:l,x:f,y:P}=i,C=m.find(h=>h.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(h=>h.imageName===d))return;const S=C.rects.map(h=>h.imageName===d?O(L({},h),{width:r,height:l,x:f,y:P}):h),F=O(L({},C),{rects:S}),I=m.map(h=>h.id===n?F:h);return t==null||t.updatePolygonList(I!=null?I:[]),I},Ut=i=>{const{boxID:n,imageName:d}=i,r=m.find(C=>C.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),f=O(L({},r),{rects:l}),P=m.map(C=>C.id===n?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},Tt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(i||(_==null?void 0:_.info)){const P=i!=null?i:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){Z({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:n});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,r,B)}}},pt=(i,n,d)=>{if(ut){let r,l;switch(d){case y.Back:r=fo;break;case y.Side:r=Lt;break;default:r=Lt;break}if(l=r(i,n,ut,s.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Jt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:S})}const P=E(rt({tool:it.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const x=St(l);return l=x.find(S=>S.id===l.id),Z({omitView:C?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},gt=(i,n,d)=>{if(J){let r,l;switch(d){case y.Back:r=go;break;case y.Side:r=vt;break;default:r=vt;break}l=r(i,n,J);const f=b(l);return Q(d,i,l,void 0,f,B),f}},zt=(i,n)=>{gt(i,n,y.Side)},jt=(i,n)=>{gt(i,n,y.Back)},Nt=(i,n)=>{pt(i,n,y.Side)},Et=(i,n)=>{pt(i,n,y.Back)},Ft=(i,n)=>{const d=N(i.id),r=dt(i,n,ot,d),l=b(r);Q(y.Top,i,r,void 0,l,B)},Ht=(i,n)=>{if(T){const r=L({},i[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,n)),U(r);return}let d=i.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=at(r,n,t.pointCloudInstance,l);return f});if(d=E(rt({tool:it.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=tt(d);Z({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(r)}},Wt=i=>{var n,d,r,l,f;if(_){const P=Number(i.widthDefault),C=Number(i.depthDefault),x=Number(i.heightDefault),S=_==null?void 0:_.info.trackID,I=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),h={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,h)),et=w.getModifiedRectangleCoordinates(z,x,P),nt=et[0],M=et[2],X=w.getLineCenterPoint([nt,M]),Zt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:X.x,y:X.y,z:Zt+C/2},width:P,height:x,depth:C,valid:!0}),Mt=tt([ft]);Z({omitView:y["3D"],polygon:I,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(i,n,d,r,l,f)=>lt(void 0,null,function*(){const P=W==null?void 0:W.url,C={[y.Side]:()=>{yt(d,n,s,P,f)},[y.Back]:()=>{a&&bt(d,n,a,P,f)},[y.Top]:()=>{It(d,n,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(d)}),Z=i=>lt(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=i,P=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[y.Side]:()=>{Bt(r,d,s,P)},[y.Back]:()=>{a&&wt(r,d,a,P)},[y.Top]:()=>{ct(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:Rt,topViewAddBox:At,topViewSelectedChanged:Tt,topViewUpdatePoint:Ft,sideViewUpdatePoint:zt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=V.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>lt(void 0,[...i],function*(n=W){var d,r,l,f,P,C;if(!(n==null?void 0:n.url)||!o)return;H([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(n.url,(d=B==null?void 0:B.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],S=[],F=[],I=[];o.updateTopCamera();const h=(l=(r=st(n.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(h),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),n.result){if(x=V.getBoxParamsFromResultList(n.result),(x==null?void 0:x.length)>0&&n.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(n.url,B,x);const z=st(n.result);z[Qt].result=x,n.result=JSON.stringify(z),e.setPointCloudResult(x)}F=V.getPolygonListFromResultList(n.result),S=V.getLineListFromResultList(n.result),I=V.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=B==null?void 0:B.radius)!=null?C:K}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(x,[])}j({pointCloudBoxList:x,polygonList:F,lineList:S,pointCloudSphereList:I}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:kt,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,Co as usePointCloudViews};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as AnnotationView}from"./components/AnnotationView/index.js";export{default as PointCloudAnnotationView}from"./components/AnnotationView/pointCloudAnnotationView.js";export{default as QuestionView}from"./components/LLMToolView/questionView/index.js";export{default as TextContent}from"./components/NLPToolView/textContent/index.js";import{i18n as l}from"@labelbee/lb-utils";export{i18n}from"@labelbee/lb-utils";import r,{useState as c,useImperativeHandle as m}from"react";import{I18nextProvider as f}from"react-i18next";import{Provider as u}from"react-redux";import x from"./App.js";import w from"./configureStore.js";import{PageBackward as P,PageForward as v,PageJump as T}from"./store/annotation/actionCreators.js";export{VideoTagTool}from"./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js";import{PointCloudProvider as g}from"./components/pointCloudView/PointCloudContext.js";import{LabelBeeContext as j}from"./store/ctx.js";export{default as PredictTracking}from"./components/predictTracking/predictTrackingIcon/index.js";export{default as LLMToolView}from"./components/LLMToolView/index.js";export{default as SwitchCuboidBoxIn2DView}from"./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js";export{default as MeasureCanvas}from"./components/measureCanvas/index.js";export{default as AnnotatedBox}from"./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js";export{FindTrackIDIndexInCheckMode as FindTrackIDIndex}from"./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js";export{WrapAudioPlayer as AudioPlayer}from"./components/audioPlayer/index.js";export{EDataFormatType,ELLMDataType,EStepType,ESubmitType,componentCls,prefix}from"./constant/index.js";var _=Object.defineProperty,I=Object.defineProperties,b=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,
|
|
1
|
+
export{default as AnnotationView}from"./components/AnnotationView/index.js";export{default as PointCloudAnnotationView}from"./components/AnnotationView/pointCloudAnnotationView.js";export{default as QuestionView}from"./components/LLMToolView/questionView/index.js";export{default as TextContent}from"./components/NLPToolView/textContent/index.js";import{i18n as l}from"@labelbee/lb-utils";export{i18n}from"@labelbee/lb-utils";import r,{useState as c,useImperativeHandle as m}from"react";import{I18nextProvider as f}from"react-i18next";import{Provider as u}from"react-redux";import x from"./App.js";import w from"./configureStore.js";import{PageBackward as P,PageForward as v,PageJump as T}from"./store/annotation/actionCreators.js";export{VideoTagTool}from"./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js";import{PointCloudProvider as g}from"./components/pointCloudView/PointCloudContext.js";import{LabelBeeContext as j}from"./store/ctx.js";export{default as PredictTracking}from"./components/predictTracking/predictTrackingIcon/index.js";export{default as LLMToolView}from"./components/LLMToolView/index.js";export{default as SwitchCuboidBoxIn2DView}from"./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js";export{default as MeasureCanvas}from"./components/measureCanvas/index.js";export{default as AnnotatedBox}from"./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js";export{FindTrackIDIndexInCheckMode as FindTrackIDIndex}from"./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js";export{WrapAudioPlayer as AudioPlayer}from"./components/audioPlayer/index.js";export{generatePointCloudBoxRects}from"./utils/index.js";export{EDataFormatType,ELLMDataType,EStepType,ESubmitType,componentCls,prefix}from"./constant/index.js";var _=Object.defineProperty,I=Object.defineProperties,b=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,p=(o,e,t)=>e in o?_(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,A=(o,e)=>{for(var t in e||(e={}))C.call(e,t)&&p(o,t,e[t]);if(s)for(var t of s(e))V.call(e,t)&&p(o,t,e[t]);return o},y=(o,e)=>I(o,b(e));const n=w(),O=(o,e)=>{const[t,d]=c();return m(e,()=>({toolInstance:t,annotationEngine:n.getState().annotation.annotationEngine,pageBackwardActions:()=>n.dispatch(P()),pageForwardActions:()=>n.dispatch(v()),pageJump:a=>{const i=~~a-1;n.dispatch(T(i))},hello:()=>alert("hello labelBee!!!")}),[t]),r.createElement(u,{store:n,context:j},r.createElement(f,{i18n:l},r.createElement(g,null,r.createElement(x,y(A({},o),{setToolInstance:a=>{var i;d(a),(i=o.onLoad)==null||i.call(o,{toolInstance:a})}})))))};var E=r.forwardRef(O);export{E as default,n as store};
|
package/es/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import g from"lodash";import{pointCloudLidar2image as y}from"@labelbee/lb-annotation";var x=Object.defineProperty,_=Object.defineProperties,O=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&m(e,n,t[n]);if(h)for(var n of h(t))w.call(t,n)&&m(e,n,t[n]);return e},I=(e,t)=>_(e,O(t));const v=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):g.isObject(e)?e:t}catch(n){return t}},j=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(g.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},l=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},u=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),s=Math.min(t.y+t.height,n.y+n.height),a=i-r,c=s-o;return a>=0&&c>=0?{x:r,y:o,width:a,height:c}:null};return(t,n,r)=>{if(r[n]){const o=r[n].width,i=r[n].height;return e(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),d=e=>{var t;const{pointCloudBox:n,mappingData:r,imageSizes:o}=e,{transferViewData:i}=(t=y(n,r.calib))!=null?t:{};if(!i)return;const s=i.reduce((p,f)=>f.type==="line"?[...p,...f.pointList]:p,[]),a=I(b({},l(s)),{imageName:r.path});if(u(a,r.path,o))return a},R=e=>{const{pointCloudBox:t,mappingImgList:n,imageSizes:r}=e,i=n.map(s=>d({pointCloudBox:t,mappingData:s,imageSizes:r})).filter(s=>s!==void 0);i.length>0&&Object.assign(t,{rects:i})};export{j as classnames,R as generatePointCloudBoxRects,l as getBoundingRect,d as getRectPointCloudBox,u as isBoundingRectInImage,v as jsonParser};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.23.0-alpha.
|
|
3
|
+
"version": "1.23.0-alpha.32",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.27.0-alpha.
|
|
47
|
-
"@labelbee/lb-utils": "1.19.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.27.0-alpha.14",
|
|
47
|
+
"@labelbee/lb-utils": "1.19.0-alpha.8",
|
|
48
48
|
"@labelbee/wavesurfer": "1.0.0",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|
|
50
50
|
"@types/react-transition-group": "^4.4.9",
|