@labelbee/lb-annotation 1.27.0-alpha.4 → 1.27.0-alpha.5
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/core/pointCloud/index.js +1 -1
- package/dist/core/pointCloud/matrix.js +1 -1
- package/dist/core/pointCloud/omniCamera.js +1 -0
- package/dist/index.js +1 -1
- package/dist/types/core/pointCloud/matrix.d.ts +1 -0
- package/dist/types/core/pointCloud/omniCamera.d.ts +9 -0
- package/es/core/pointCloud/index.js +1 -1
- package/es/core/pointCloud/matrix.js +1 -1
- package/es/core/pointCloud/omniCamera.js +1 -0
- package/es/index.js +1 -1
- package/package.json +3 -2
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
|
|
29
29
|
// Output the final color
|
|
30
30
|
gl_FragColor = vec4(color, 1.0);
|
|
31
|
-
}`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...n)=>__async(this,[...n],function*(c=this.currentPCDSrc,h){if(!c)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=c;const{points:d,color:u}=yield this.cacheInstance.loadPCDFile(c),m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.BufferAttribute(d,3)),this.isSegment||m.setAttribute("dimensions",new THREE__namespace.BufferAttribute(u,3)),this.initCloudData(d);const p=new THREE__namespace.Points(m);this.renderPointCloud(p,h),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=n=>__async(this,[n],function*({mappingImgList:c,points:h}){const d=c.length===0?[]:yield Promise.all(c.map(p=>ImgUtils.default.load(p.url))),u=c.map((p,g)=>{var y;if(this.cacheInstance.cache2DHighlightIndex.has(p.url))return(y=this.cacheInstance.cache2DHighlightIndex.get(p.url))!=null?y:[];const x=matrix.getHighlightIndexByPoints({points:h,calib:p.calib,width:d[g].width,height:d[g].height});return this.cacheInstance.cache2DHighlightIndex.set(p.url,x),x});return matrix.mergeHighlightList(u)}),this.filterPreResult=(n,c,h)=>__async(this,null,function*(){const{points:d}=yield this.cacheInstance.loadPCDFile(n),u=yield this.cacheInstance.loadIndexMap(n,d);return new Promise(m=>{const p=h.map(g=>{const y=MathUtils.default.calculatePointsInsideBox({indexMap:u,polygon:matrix.getCuboidFromPointCloudBox(g).polygonPointList,zScope:[g.center.z-g.depth/2,g.center.z+g.depth/2],box:g}),x=y>=c.lowerLimitPointsNumInBox;return __spreadProps(__spreadValues({},g),{valid:x,count:y})});m(p)})}),this.loadPCDFileByBox=(n,c,h)=>__async(this,null,function*(){const d=(p,g)=>__async(this,null,function*(){const{width:y=0,height:x=0,depth:w=0}=h!=null?h:{},C=yield this.filterPointsByBox(__spreadProps(__spreadValues({},c),{width:c.width+y,height:c.height+x,depth:c.depth+w}),p,g);if(!C){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=n;const b=new THREE__namespace.Points(C.geometry);b.name=this.pointCloudObjectName,this.scene.add(b),this.render()}),{points:u,color:m}=yield this.cacheInstance.loadPCDFile(n);d(u,m)}),this.generateRange=n=>{const c=this.createRange(n);this.scene.add(c)},this.generateBoxArrow=({width:n})=>{const c=new THREE__namespace.Vector3(1,0,0),h=new THREE__namespace.Vector3(n/2,0,0),d=2,u=16776960,m=new THREE__namespace.ArrowHelper(c,h,d,u);return m.visible=this.showDirection,m},this.generateBoxTrackID=n=>{if(!n.trackID)return;const c=new THREE__namespace.Texture(this.getTextCanvas(n.trackID.toString()));c.needsUpdate=!0;const h=new THREE__namespace.SpriteMaterial({map:c,depthWrite:!1}),d=new THREE__namespace.Sprite(h);return d.scale.set(5,5,5),d.position.set(-n.width/2,0,n.depth/2+.5),d},this.applyZAxisPoints=n=>{this.zAxisLimit=n,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:n,customSize:c})=>{const h=this.scene.getObjectByName(this.pointCloudObjectName);if(!h)return;const d=h.material.uniforms.pointSize.value;n?h.material.uniforms.pointSize.value=Math.min(d*1.2,10):h.material.uniforms.pointSize.value=Math.max(d/1.2,1),c&&(h.material.uniforms.pointSize.value=c,this.pointsMaterialSize=c),h.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=o,this.config=a,this.checkMode=l!=null?l:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,s?this.container:this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance(),s===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new index(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new segmentation.PointCloudSegmentOperation(__spreadValues({dom:this.container,store:this.store},this.eventBus)),this.pointCloudRender=new index$1(__spreadProps(__spreadValues({store:this.store},this.eventBus),{nextTick:this.nextTick})),this.initMsg(),document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup)}orbiterStart(){}orbiterChange(){!this.store||(this.store.orbiting=!0)}orbiterEnd(){!this.store||(this.store.orbiting=!1)}get currentSegmentTool(){var t;return(t=this.segmentOperation)==null?void 0:t.currentToolName}get pointCloudObject(){return this.scene.getObjectByName(this.pointCloudObjectName)}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.on("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.on("clearPointCloud",this.clearPointCloud.bind(this)),this.on("loadPCDFile",this.loadPCDFile.bind(this)))}unbindMsg(){!this.segmentOperation||(this.unbind("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.unbind("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.unbind("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.unbind("clearPointCloud",this.clearPointCloud.bind(this)),this.unbind("loadPCDFile",this.loadPCDFile.bind(this)))}get eventBus(){return{on:this.on.bind(this),emit:this.emit.bind(this),unbind:this.unbind.bind(this)}}get pointCloudDelegate(){return __spreadValues({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode,config:this.config},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new THREE__namespace.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){var e;this.config=t,(e=this.store)==null||e.setConfig(t)}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:o,near:a,far:s}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=o,this.camera.near=a,this.camera.far=s,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:i,z:r}=this.initCameraPosition;t.position.set(e,i,r)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new THREE__namespace.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new THREE__namespace.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}getColorFromConfig(t){return lbUtils.toolStyleConverter.getColorFromConfig({attribute:t},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{})}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=this.getColorFromConfig(i.attribute),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,o=10,a=e.x-i/2-o,s=e.x-i/2+o,l=e.y+r/2+o,n=e.y-r/2-o,c=100,h=-100,d=500/c;return{left:a,right:s,top:l,bottom:n,near:c,far:h,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:o,height:a,depth:s,rotation:l}=t,n=this.getCameraVector(r,l,{width:o,height:a,depth:s},e);return i?(this.updateCamera(i,r),new THREE__namespace.Vector3(i.x,i.y,i.z)):(this.updateCamera(n,r),n)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=lbUtils.DEFAULT_SPHERE_PARAMS,o=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,o,a;if(!e){const s=this.scene.getObjectByName(this.pointCloudObjectName);if(!s)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:a.array}if(window.Worker){const{zMin:s,zMax:l,polygonPointList:n}=matrix.getCuboidFromPointCloudBox(t),c=e;i=i!=null?i:new Float32Array([]);const h={boxParams:t,zMin:s,zMax:l,polygonPointList:n,color:i,position:c};return new Promise(d=>{const u=new filterBoxWorker;u.postMessage(h),u.onmessage=m=>{const{color:p,position:g,num:y}=m.data,x=new THREE__namespace.BufferGeometry;x.setAttribute("position",new THREE__namespace.Float32BufferAttribute(g,3)),x.setAttribute("color",new THREE__namespace.Float32BufferAttribute(p,3)),x.computeBoundingSphere(),u.terminate(),d({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,o=DEFAULT_DISTANCE){let a=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(o);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:a=lbUtils.PerspectiveShiftUtils.backViewMatrix4(o);break;case lbUtils.EPerspectiveView.Left:a=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(o);break;case lbUtils.EPerspectiveView.Right:a=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(o);break;case lbUtils.EPerspectiveView.Top:a=lbUtils.PerspectiveShiftUtils.topViewMatrix4(o);break;case lbUtils.EPerspectiveView.LFT:a=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(o,i);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(o,i);break}const s=this.createThreeMatrix4(a),l=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),n=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(s).applyMatrix4(l).applyMatrix4(c).applyMatrix4(n)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new THREE__namespace.BufferGeometry().setFromPoints(i),o=new THREE__namespace.LineBasicMaterial({color:16711680}),a=new THREE__namespace.Line(r,o);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new THREE__namespace.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],o=t[e+2];this.store.cloudData.set(`${i}@${r}@${o}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return __async(this,null,function*(){return new Promise((e,i)=>{if(this.workerLoading){i(new Error("workerLoading"));return}this.workerLoading=!0,highlightWorker.postMessage(t),highlightWorker.onmessage=r=>{e(r.data),this.workerLoading=!1},highlightWorker.onerror=r=>{i(r),this.workerLoading=!1}})})}highlightOriginPointCloud(t){return __async(this,arguments,function*(e,i=[]){const r=this.scene.getObjectByName(this.pointCloudObjectName);if(!!r)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((o,a)=>{if(window.Worker){const l=(e?[...e]:[]).map(h=>matrix.getCuboidFromPointCloudBox(h)),n=this.getAllAttributeColor(l),c={cuboidList:l,position:r.geometry.attributes.position.array,color:r.geometry.attributes.dimensions.array,colorList:n,highlightIndex:i};this.handleWebworker(c).then(h=>{const{color:d}=h,u=new THREE__namespace.BufferAttribute(d,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||r.geometry.attributes.position.array.length!==d.length){a(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,d),this.highlightPCDSrc=void 0,u.needsUpdate=!0,r.geometry.setAttribute("dimensions",u),r.geometry.attributes.dimensions.needsUpdate=!0,o(d),this.render()}).catch(h=>{a(h)})}})})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new THREE__namespace.Group;t.forEach(i=>{const{center:{x:r,y:o,z:a},width:s,height:l,depth:n,rotation:c}=i,{fill:h}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),d=new THREE__namespace.BoxGeometry(s,l,n),u=new THREE__namespace.MeshBasicMaterial({color:h,transparent:!0,opacity:.2,depthTest:!1});d.rotateZ(c),d.translate(r,o,a);const m=new THREE__namespace.Mesh(d,u);e.add(m);const p=new THREE__namespace.PlaneGeometry(n,l);p.rotateY(Math.PI/2),p.rotateZ(c);const g=new THREE__namespace.Vector3(s/2,0,0),y=new THREE__namespace.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(c);g.applyMatrix4(y),p.translate(r+g.x,o+g.y,a+g.z);const x=new THREE__namespace.MeshBasicMaterial({color:h,side:THREE__namespace.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),w=new THREE__namespace.Mesh(p,x);e.add(w)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((h,d)=>h.z-d.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:h})=>h>r.z+.1);const o=.005,a=Math.floor(e.length*(1-o));e=e.slice(0,a),e.sort((h,d)=>h.x-d.x);const s=Math.floor(e.length*o),l=Math.floor(e.length*(1-o));e=e.slice(s,l),e.sort((h,d)=>h.y-d.y);const n=Math.floor(e.length*o),c=Math.floor(e.length*(1-o));return e=e.slice(n,c),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:l,y:n})=>{t.forEach((c,h)=>{const d=r[h+1],u=MathUtils.default.getFootOfPerpendicular({x:l,y:n},c,d,!1,!0).length;(!i[h]||u<i[h].distance)&&(i[h]={distance:u,point:{x:l,y:n}})})}),r=[t[t.length-1],...t,t[0]];const o=[i[i.length-1],...i],a=t.map((l,n)=>{const c=r[n],h=r[n+1],d=r[n+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:o[n].point,line1:[c,h],p2:o[n+1].point,line2:[h,d]})});return a.some(l=>!(Number.isFinite(l.x)&&Number.isFinite(l.y)))?t:a}getSensesPointZAxisInPolygon(t,e,i){var r,o,a;const s=this.scene.children.find(p=>p.uuid===this.pointsUuid);let l=0,n=0,c=0,h=0,d=[],u=[];const m=((a=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:a.array)||[];for(let p=0;p<m.length;p+=3){const g=m[p],y=m[p+1],x=m[p+2];polygonTool.isInPolygon({x:g,y},t)&&(x||x===0)&&u.push({x:g,y,z:x})}return u.length?(i&&(u=this.filterNoise(u),d=this.getFittedCoordinates(t,u)),u.sort((p,g)=>p.z-g.z),l=u[0].z-.01,n=u[u.length-1].z+.01,h=u.length,e&&(c=u.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:n,minZ:l,count:c,zCount:h,fittedCoordinates:d}):{maxZ:n,minZ:l,count:c,zCount:h,fittedCoordinates:d}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e+a/2,y:i+o/2,z:r-s/2},n={x:e+a/2,y:i+o/2,z:r+s/2},c={x:e-a/2,y:i+o/2,z:r+s/2},h={x:e-a/2,y:i+o/2,z:r-s/2};return[l,n,c,h]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e-a/2,y:i+o/2,z:r+s/2},n={x:e-a/2,y:i+o/2,z:r-s/2},c={x:e-a/2,y:i-o/2,z:r-s/2},h={x:e-a/2,y:i-o/2,z:r+s/2};return[l,n,c,h]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e+a/2,y:i+o/2,z:r+s/2},n={x:e+a/2,y:i-o/2,z:r+s/2},c={x:e-a/2,y:i-o/2,z:r+s/2},h={x:e-a/2,y:i+o/2,z:r+s/2};return[l,n,c,h]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:o}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),s=new THREE__namespace.Matrix4().makeTranslation(e,i,r),l=new THREE__namespace.Matrix4().makeRotationZ(o);return new THREE__namespace.Matrix4().multiply(s).multiply(l).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:o}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const l=i.map(h=>new THREE__namespace.Vector3(h.x,h.y,h.z)).map(h=>h.applyMatrix4(this.sideMatrix)),n=this.containerWidth/r,c=this.containerHeight/o;return{polygon2d:l,zoom:Math.min(n,c)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:o}=t,{radius:a}=lbUtils.DEFAULT_SPHERE_PARAMS,s={center:e,attribute:i,id:r,valid:o,width:a*2,height:a*2,depth:a*2,rotation:0},l=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(s)).premultiply(l).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const c=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),h=this.containerWidth/(a*2),d=this.containerHeight/(a*2);return{point2d:c,zoom:Math.min(h,d)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=lbUtils.DEFAULT_SPHERE_PARAMS,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},o=this.containerWidth/(i*2),a=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(o,a)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,o=this.getPolygonTopPoints(t).map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.getModelTransformationMatrix(t))).map(l=>({x:l.y,y:l.x})).map(l=>({x:-(l.x-this.containerWidth/2),y:-(l.y-this.containerHeight/2)})),a=this.containerWidth/e,s=this.containerHeight/i;return{polygon2d:o,zoom:Math.min(a,s)/2}}getNewBoxBySideUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+a.x,y:s.center.y+a.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:Math.abs(s.width+e),height:s.height,depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxByBackUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+a.x,y:s.center.y+a.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:s.width,height:Math.abs(s.height+e),depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxBySideUpdateByPoints(t,e,i,r){var o;const a=(o=this.sideMatrix)==null?void 0:o.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const s=t.map(g=>new THREE__namespace.Vector3(g.x,g.y,g.z)).map(g=>g.applyMatrix4(a)),[l,n,c,h]=s,d=Math.max(Math.abs(l.x-c.x),Math.abs(l.x-n.x)),m=n.add(h).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:__spreadProps(__spreadValues({},r),{center:{x:r.center.x-m.x,y:r.center.y-m.y,z:r.center.z-i},width:d,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,o=[],{count:a}=r;for(let s=0;s<a;s++){const l=r.getZ(s);o.push(l>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(o,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isFisheyeCalibValid=matrix.isFisheyeCalibValid,exports.isInImage=matrix.isInImage,exports.isMatrixValid=matrix.isMatrixValid,exports.isMatrixValidByArr=matrix.isMatrixValidByArr,exports.lidar2FisheyeImage=matrix.lidar2FisheyeImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.oCamFisheyeTransfer=matrix.oCamFisheyeTransfer,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.pointListLidar2Img=matrix.pointListLidar2Img,exports.pointMappingLidar2image=matrix.pointMappingLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
|
|
31
|
+
}`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...n)=>__async(this,[...n],function*(c=this.currentPCDSrc,h){if(!c)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=c;const{points:d,color:u}=yield this.cacheInstance.loadPCDFile(c),m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.BufferAttribute(d,3)),this.isSegment||m.setAttribute("dimensions",new THREE__namespace.BufferAttribute(u,3)),this.initCloudData(d);const p=new THREE__namespace.Points(m);this.renderPointCloud(p,h),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=n=>__async(this,[n],function*({mappingImgList:c,points:h}){const d=c.length===0?[]:yield Promise.all(c.map(p=>ImgUtils.default.load(p.url))),u=c.map((p,g)=>{var y;if(this.cacheInstance.cache2DHighlightIndex.has(p.url))return(y=this.cacheInstance.cache2DHighlightIndex.get(p.url))!=null?y:[];const x=matrix.getHighlightIndexByPoints({points:h,calib:p.calib,width:d[g].width,height:d[g].height});return this.cacheInstance.cache2DHighlightIndex.set(p.url,x),x});return matrix.mergeHighlightList(u)}),this.filterPreResult=(n,c,h)=>__async(this,null,function*(){const{points:d}=yield this.cacheInstance.loadPCDFile(n),u=yield this.cacheInstance.loadIndexMap(n,d);return new Promise(m=>{const p=h.map(g=>{const y=MathUtils.default.calculatePointsInsideBox({indexMap:u,polygon:matrix.getCuboidFromPointCloudBox(g).polygonPointList,zScope:[g.center.z-g.depth/2,g.center.z+g.depth/2],box:g}),x=y>=c.lowerLimitPointsNumInBox;return __spreadProps(__spreadValues({},g),{valid:x,count:y})});m(p)})}),this.loadPCDFileByBox=(n,c,h)=>__async(this,null,function*(){const d=(p,g)=>__async(this,null,function*(){const{width:y=0,height:x=0,depth:w=0}=h!=null?h:{},C=yield this.filterPointsByBox(__spreadProps(__spreadValues({},c),{width:c.width+y,height:c.height+x,depth:c.depth+w}),p,g);if(!C){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=n;const b=new THREE__namespace.Points(C.geometry);b.name=this.pointCloudObjectName,this.scene.add(b),this.render()}),{points:u,color:m}=yield this.cacheInstance.loadPCDFile(n);d(u,m)}),this.generateRange=n=>{const c=this.createRange(n);this.scene.add(c)},this.generateBoxArrow=({width:n})=>{const c=new THREE__namespace.Vector3(1,0,0),h=new THREE__namespace.Vector3(n/2,0,0),d=2,u=16776960,m=new THREE__namespace.ArrowHelper(c,h,d,u);return m.visible=this.showDirection,m},this.generateBoxTrackID=n=>{if(!n.trackID)return;const c=new THREE__namespace.Texture(this.getTextCanvas(n.trackID.toString()));c.needsUpdate=!0;const h=new THREE__namespace.SpriteMaterial({map:c,depthWrite:!1}),d=new THREE__namespace.Sprite(h);return d.scale.set(5,5,5),d.position.set(-n.width/2,0,n.depth/2+.5),d},this.applyZAxisPoints=n=>{this.zAxisLimit=n,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:n,customSize:c})=>{const h=this.scene.getObjectByName(this.pointCloudObjectName);if(!h)return;const d=h.material.uniforms.pointSize.value;n?h.material.uniforms.pointSize.value=Math.min(d*1.2,10):h.material.uniforms.pointSize.value=Math.max(d/1.2,1),c&&(h.material.uniforms.pointSize.value=c,this.pointsMaterialSize=c),h.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=o,this.config=a,this.checkMode=l!=null?l:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,s?this.container:this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance(),s===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new index(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new segmentation.PointCloudSegmentOperation(__spreadValues({dom:this.container,store:this.store},this.eventBus)),this.pointCloudRender=new index$1(__spreadProps(__spreadValues({store:this.store},this.eventBus),{nextTick:this.nextTick})),this.initMsg(),document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup)}orbiterStart(){}orbiterChange(){!this.store||(this.store.orbiting=!0)}orbiterEnd(){!this.store||(this.store.orbiting=!1)}get currentSegmentTool(){var t;return(t=this.segmentOperation)==null?void 0:t.currentToolName}get pointCloudObject(){return this.scene.getObjectByName(this.pointCloudObjectName)}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.on("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.on("clearPointCloud",this.clearPointCloud.bind(this)),this.on("loadPCDFile",this.loadPCDFile.bind(this)))}unbindMsg(){!this.segmentOperation||(this.unbind("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.unbind("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.unbind("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.unbind("clearPointCloud",this.clearPointCloud.bind(this)),this.unbind("loadPCDFile",this.loadPCDFile.bind(this)))}get eventBus(){return{on:this.on.bind(this),emit:this.emit.bind(this),unbind:this.unbind.bind(this)}}get pointCloudDelegate(){return __spreadValues({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode,config:this.config},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new THREE__namespace.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){var e;this.config=t,(e=this.store)==null||e.setConfig(t)}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:o,near:a,far:s}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=o,this.camera.near=a,this.camera.far=s,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:i,z:r}=this.initCameraPosition;t.position.set(e,i,r)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new THREE__namespace.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new THREE__namespace.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}getColorFromConfig(t){return lbUtils.toolStyleConverter.getColorFromConfig({attribute:t},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{})}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=this.getColorFromConfig(i.attribute),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,o=10,a=e.x-i/2-o,s=e.x-i/2+o,l=e.y+r/2+o,n=e.y-r/2-o,c=100,h=-100,d=500/c;return{left:a,right:s,top:l,bottom:n,near:c,far:h,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:o,height:a,depth:s,rotation:l}=t,n=this.getCameraVector(r,l,{width:o,height:a,depth:s},e);return i?(this.updateCamera(i,r),new THREE__namespace.Vector3(i.x,i.y,i.z)):(this.updateCamera(n,r),n)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=lbUtils.DEFAULT_SPHERE_PARAMS,o=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,o,a;if(!e){const s=this.scene.getObjectByName(this.pointCloudObjectName);if(!s)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:a.array}if(window.Worker){const{zMin:s,zMax:l,polygonPointList:n}=matrix.getCuboidFromPointCloudBox(t),c=e;i=i!=null?i:new Float32Array([]);const h={boxParams:t,zMin:s,zMax:l,polygonPointList:n,color:i,position:c};return new Promise(d=>{const u=new filterBoxWorker;u.postMessage(h),u.onmessage=m=>{const{color:p,position:g,num:y}=m.data,x=new THREE__namespace.BufferGeometry;x.setAttribute("position",new THREE__namespace.Float32BufferAttribute(g,3)),x.setAttribute("color",new THREE__namespace.Float32BufferAttribute(p,3)),x.computeBoundingSphere(),u.terminate(),d({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=lbUtils.EPerspectiveView.Front,o=DEFAULT_DISTANCE){let a=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(o);switch(r){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:a=lbUtils.PerspectiveShiftUtils.backViewMatrix4(o);break;case lbUtils.EPerspectiveView.Left:a=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(o);break;case lbUtils.EPerspectiveView.Right:a=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(o);break;case lbUtils.EPerspectiveView.Top:a=lbUtils.PerspectiveShiftUtils.topViewMatrix4(o);break;case lbUtils.EPerspectiveView.LFT:a=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(o,i);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(o,i);break}const s=this.createThreeMatrix4(a),l=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),n=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(s).applyMatrix4(l).applyMatrix4(c).applyMatrix4(n)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new THREE__namespace.BufferGeometry().setFromPoints(i),o=new THREE__namespace.LineBasicMaterial({color:16711680}),a=new THREE__namespace.Line(r,o);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new THREE__namespace.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],o=t[e+2];this.store.cloudData.set(`${i}@${r}@${o}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return __async(this,null,function*(){return new Promise((e,i)=>{if(this.workerLoading){i(new Error("workerLoading"));return}this.workerLoading=!0,highlightWorker.postMessage(t),highlightWorker.onmessage=r=>{e(r.data),this.workerLoading=!1},highlightWorker.onerror=r=>{i(r),this.workerLoading=!1}})})}highlightOriginPointCloud(t){return __async(this,arguments,function*(e,i=[]){const r=this.scene.getObjectByName(this.pointCloudObjectName);if(!!r)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((o,a)=>{if(window.Worker){const l=(e?[...e]:[]).map(h=>matrix.getCuboidFromPointCloudBox(h)),n=this.getAllAttributeColor(l),c={cuboidList:l,position:r.geometry.attributes.position.array,color:r.geometry.attributes.dimensions.array,colorList:n,highlightIndex:i};this.handleWebworker(c).then(h=>{const{color:d}=h,u=new THREE__namespace.BufferAttribute(d,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||r.geometry.attributes.position.array.length!==d.length){a(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,d),this.highlightPCDSrc=void 0,u.needsUpdate=!0,r.geometry.setAttribute("dimensions",u),r.geometry.attributes.dimensions.needsUpdate=!0,o(d),this.render()}).catch(h=>{a(h)})}})})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new THREE__namespace.Group;t.forEach(i=>{const{center:{x:r,y:o,z:a},width:s,height:l,depth:n,rotation:c}=i,{fill:h}=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),d=new THREE__namespace.BoxGeometry(s,l,n),u=new THREE__namespace.MeshBasicMaterial({color:h,transparent:!0,opacity:.2,depthTest:!1});d.rotateZ(c),d.translate(r,o,a);const m=new THREE__namespace.Mesh(d,u);e.add(m);const p=new THREE__namespace.PlaneGeometry(n,l);p.rotateY(Math.PI/2),p.rotateZ(c);const g=new THREE__namespace.Vector3(s/2,0,0),y=new THREE__namespace.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(c);g.applyMatrix4(y),p.translate(r+g.x,o+g.y,a+g.z);const x=new THREE__namespace.MeshBasicMaterial({color:h,side:THREE__namespace.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),w=new THREE__namespace.Mesh(p,x);e.add(w)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((h,d)=>h.z-d.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:h})=>h>r.z+.1);const o=.005,a=Math.floor(e.length*(1-o));e=e.slice(0,a),e.sort((h,d)=>h.x-d.x);const s=Math.floor(e.length*o),l=Math.floor(e.length*(1-o));e=e.slice(s,l),e.sort((h,d)=>h.y-d.y);const n=Math.floor(e.length*o),c=Math.floor(e.length*(1-o));return e=e.slice(n,c),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:l,y:n})=>{t.forEach((c,h)=>{const d=r[h+1],u=MathUtils.default.getFootOfPerpendicular({x:l,y:n},c,d,!1,!0).length;(!i[h]||u<i[h].distance)&&(i[h]={distance:u,point:{x:l,y:n}})})}),r=[t[t.length-1],...t,t[0]];const o=[i[i.length-1],...i],a=t.map((l,n)=>{const c=r[n],h=r[n+1],d=r[n+2];return lbUtils.PointCloudUtils.getIntersectionBySlope({p1:o[n].point,line1:[c,h],p2:o[n+1].point,line2:[h,d]})});return a.some(l=>!(Number.isFinite(l.x)&&Number.isFinite(l.y)))?t:a}getSensesPointZAxisInPolygon(t,e,i){var r,o,a;const s=this.scene.children.find(p=>p.uuid===this.pointsUuid);let l=0,n=0,c=0,h=0,d=[],u=[];const m=((a=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:a.array)||[];for(let p=0;p<m.length;p+=3){const g=m[p],y=m[p+1],x=m[p+2];polygonTool.isInPolygon({x:g,y},t)&&(x||x===0)&&u.push({x:g,y,z:x})}return u.length?(i&&(u=this.filterNoise(u),d=this.getFittedCoordinates(t,u)),u.sort((p,g)=>p.z-g.z),l=u[0].z-.01,n=u[u.length-1].z+.01,h=u.length,e&&(c=u.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:n,minZ:l,count:c,zCount:h,fittedCoordinates:d}):{maxZ:n,minZ:l,count:c,zCount:h,fittedCoordinates:d}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e+a/2,y:i+o/2,z:r-s/2},n={x:e+a/2,y:i+o/2,z:r+s/2},c={x:e-a/2,y:i+o/2,z:r+s/2},h={x:e-a/2,y:i+o/2,z:r-s/2};return[l,n,c,h]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e-a/2,y:i+o/2,z:r+s/2},n={x:e-a/2,y:i+o/2,z:r-s/2},c={x:e-a/2,y:i-o/2,z:r-s/2},h={x:e-a/2,y:i-o/2,z:r+s/2};return[l,n,c,h]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:o,width:a,depth:s}=t,l={x:e+a/2,y:i+o/2,z:r+s/2},n={x:e+a/2,y:i-o/2,z:r+s/2},c={x:e-a/2,y:i-o/2,z:r+s/2},h={x:e-a/2,y:i+o/2,z:r+s/2};return[l,n,c,h]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:o}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-r),s=new THREE__namespace.Matrix4().makeTranslation(e,i,r),l=new THREE__namespace.Matrix4().makeRotationZ(o);return new THREE__namespace.Matrix4().multiply(s).multiply(l).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:o}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const l=i.map(h=>new THREE__namespace.Vector3(h.x,h.y,h.z)).map(h=>h.applyMatrix4(this.sideMatrix)),n=this.containerWidth/r,c=this.containerHeight/o;return{polygon2d:l,zoom:Math.min(n,c)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:o}=t,{radius:a}=lbUtils.DEFAULT_SPHERE_PARAMS,s={center:e,attribute:i,id:r,valid:o,width:a*2,height:a*2,depth:a*2,rotation:0},l=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(s)).premultiply(l).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const c=new THREE__namespace.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),h=this.containerWidth/(a*2),d=this.containerHeight/(a*2);return{point2d:c,zoom:Math.min(h,d)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=lbUtils.DEFAULT_SPHERE_PARAMS,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},o=this.containerWidth/(i*2),a=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(o,a)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,o=this.getPolygonTopPoints(t).map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.getModelTransformationMatrix(t))).map(l=>({x:l.y,y:l.x})).map(l=>({x:-(l.x-this.containerWidth/2),y:-(l.y-this.containerHeight/2)})),a=this.containerWidth/e,s=this.containerHeight/i;return{polygon2d:o,zoom:Math.min(a,s)/2}}getNewBoxBySideUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+a.x,y:s.center.y+a.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:Math.abs(s.width+e),height:s.height,depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxByBackUpdate(t,e,i,r){const o=new THREE__namespace.Matrix4().makeRotationZ(r.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+a.x,y:s.center.y+a.y,z:s.center.z-t.z},s=__spreadProps(__spreadValues({},s),{width:s.width,height:Math.abs(s.height+e),depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxBySideUpdateByPoints(t,e,i,r){var o;const a=(o=this.sideMatrix)==null?void 0:o.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const s=t.map(g=>new THREE__namespace.Vector3(g.x,g.y,g.z)).map(g=>g.applyMatrix4(a)),[l,n,c,h]=s,d=Math.max(Math.abs(l.x-c.x),Math.abs(l.x-n.x)),m=n.add(h).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:__spreadProps(__spreadValues({},r),{center:{x:r.center.x-m.x,y:r.center.y-m.y,z:r.center.z-i},width:d,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,o=[],{count:a}=r;for(let s=0;s<a;s++){const l=r.getZ(s);o.push(l>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(o,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isFisheyeCalibValid=matrix.isFisheyeCalibValid,exports.isInImage=matrix.isInImage,exports.isMatrixValid=matrix.isMatrixValid,exports.isMatrixValidByArr=matrix.isMatrixValidByArr,exports.lidar2FisheyeImage=matrix.lidar2FisheyeImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.oCamFisheyeTransfer=matrix.oCamFisheyeTransfer,exports.omniCamera11VTransfer=matrix.omniCamera11VTransfer,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.pointListLidar2Img=matrix.pointListLidar2Img,exports.pointMappingLidar2image=matrix.pointMappingLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),uuid=require("../../utils/uuid.js");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__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));function createThreeMatrix4(e){return new THREE__namespace.Matrix4().set(...e)}function transferKitti2Matrix(e,t,r){try{const n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),uuid=require("../../utils/uuid.js"),omniCamera=require("./omniCamera.js");function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__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));function createThreeMatrix4(e){return new THREE__namespace.Matrix4().set(...e)}function transferKitti2Matrix(e,t,r){try{const n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),i=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),o=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),l=createThreeMatrix4(n),f=createThreeMatrix4(i),a=createThreeMatrix4(o);return{composeMatrix4:a.clone().premultiply(f).premultiply(l),PM:l,RM:f,TM:a}}catch(n){console.error(n)}}function rotatePoint(e,t,r){var n;const i=new THREE__namespace.Vector3(e.x,e.y,(n=e==null?void 0:e.z)!=null?n:1),o=new THREE__namespace.Matrix4().makeRotationZ(r),l=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),f=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return i.clone().applyMatrix4(f).applyMatrix4(o).applyMatrix4(l)}function isMatrixValid(e,t,r){return!(e.length!==t||e.some(n=>n.length!==r))}const isMatrixValidByArr=(e,t)=>t.some(r=>isMatrixValid(e,r[0],r[1])),isFisheyeCalibValid=e=>{var t;return!!(((t=e.fisheyeDistortion)==null?void 0:t.length)>0&&isMatrixValidByArr(e.P,[[3,4],[4,4]])&&isMatrixValidByArr(e.T,[[3,4],[4,4]]))},oCamFisheyeTransfer=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:r,fisheyeDistortion:n,T:i}=t,o=new THREE__namespace.Vector4(e.x,e.y,e.z),l=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(i)),f=createThreeMatrix4(lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r)),a=o.applyMatrix4(l),x=__pow(__pow(a.x,2)+__pow(a.y,2),.5),p=Math.atan(a.z/x),s=n.reduce((c,u,y)=>c+u*__pow(p,y),0);return a.x=a.x/x*s,a.y=a.y/x*s,a.z=1,a.applyMatrix4(f)},omniCamera11VTransfer=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:r,fisheyeDistortion:n,T:i}=t,o=omniCamera.transformPointCloudToImage([[e.x,e.y,e.z]],i,r,n);return new THREE__namespace.Vector4(o[0][0],o[0][1],1)},batchPolyval=(e,t)=>{const r=e.length;let n=0;const i=[];for(let o=0;o<e.length;o++)i.push(e[r-o-1]+n*t),n=e[r-o-1]+n*t;return n},kbCamFisheyeTransfer=(e,t)=>{const{P:r,fisheyeDistortion:n}=t,{x:i,y:o,z:l}=e,f=[[r[0][0],r[0][1]],[r[1][0],r[1][1]]],a=r[0][2],x=r[1][2],p=1/Math.hypot(i,o),s=[],h=Math.atan2(Math.hypot(i,o),l),c=batchPolyval(n,h);return s[0]=i*p*c,s[1]=o*p*c,{x:f[0][0]*s[0]+f[0][1]*s[1]+a,y:f[1][0]*s[0]+f[1][1]*s[1]+x}},lidar2FisheyeImage=(e,t)=>{if(isFisheyeCalibValid(t)===!1){console.error("Error Calib, it need fisheye calib");return}if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.OmniCamera)return oCamFisheyeTransfer(e,t);if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.KannalaBrandt)return kbCamFisheyeTransfer(e,t);if((t==null?void 0:t.cameraType)===lbUtils.ECameraType.OmniCamera11V)return omniCamera11VTransfer(e,t)};function lidar2image(e,t){const n=new THREE__namespace.Vector4(e.x,e.y,e.z).applyMatrix4(t);if(n.z<0)return;const i=1/n.z,o=new THREE__namespace.Matrix4().set(i,0,0,0,0,i,0,0,0,0,i,0,0,0,0,1);return n.applyMatrix4(o)}function getCuboidFromPointCloudBox(e){const{center:t,width:r,height:n,depth:i,rotation:o}=e,l=[{x:t.x+r/2,y:t.y-n/2},{x:t.x+r/2,y:t.y+n/2},{x:t.x-r/2,y:t.y+n/2},{x:t.x-r/2,y:t.y-n/2}].map(x=>{const p=rotatePoint(x,t,o);return{x:p.x,y:p.y}}),f=t.z+i/2,a=t.z-i/2;return __spreadProps(__spreadValues({},e),{polygonPointList:l,zMax:f,zMin:a})}function sortPoints(e){const t=e.slice();return t.sort((r,n)=>r.x===n.x?n.y-r.y:r.x-n.x),t}function crossProduct(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=r.x-e.x,l=r.y-e.y;return n*l-o*i}function buildConvexHull(e){const t=sortPoints(e),r=[];for(let o=0;o<t.length;o++){for(;r.length>=2&&crossProduct(r[r.length-2],r[r.length-1],t[o])<=0;)r.pop();r.push(t[o])}const n=[];for(let o=t.length-1;o>=0;o--){for(;n.length>=2&&crossProduct(n[n.length-2],n[n.length-1],t[o])<=0;)n.pop();n.push(t[o])}return r.pop(),n.pop(),r.concat(n)}const point3DLidar2Image=(e,t)=>{var r;if(isFisheyeCalibValid(t))return lidar2FisheyeImage(e,t);const{P:n,R:i,T:o}=t,{composeMatrix4:l}=(r=transferKitti2Matrix(n,i,o))!=null?r:{};if(!!l)return lidar2image(e,l)},isInImage=({point:e,calib:t,width:r,height:n})=>{if(!t)return!1;const i=point3DLidar2Image(e,t);return i?i.x>=0&&i.x<=r&&i.y>=0&&i.y<=n:!1},getHighlightIndexByPoints=({points:e,calib:t,width:r,height:n})=>{const i=[];for(let o=0;o<e.length;o+=3){const l=e[o],f=e[o+1],a=e[o+2];isInImage({point:{x:l,y:f,z:a},calib:t,width:r,height:n})?i.push(1):i.push(0)}return i},mergeHighlightList=e=>{if(e.length===0)return[];const t=[];for(let r=0;r<e[0].length;r++){for(let n=0;n<e.length;n++)if(e[n][r]===1){t.push(1);break}t.length===r&&t.push(0)}return t};function pointCloudLidar2image(e,t,r={createRange:!1}){var n;if(!t)return{transferViewData:[],viewRangePointList:[]};const{createRange:i}=r,o=lbUtils.PointCloudUtils.getAllViewData(e),l=isFisheyeCalibValid(t),{P:f,R:a,T:x}=t;let p;if(l===!1){const{composeMatrix4:c}=(n=transferKitti2Matrix(f,a,x))!=null?n:{};if(!c)return;p=c}const s=o.map(c=>({type:c.type,pointList:c.pointList.map(u=>rotatePoint(u,e.center,e.rotation)).map(u=>l?lidar2FisheyeImage(u,t):p&&lidar2image(u,p)).map(u=>{if(!!u)return{id:uuid(),x:u==null?void 0:u.x,y:u==null?void 0:u.y}}).filter(u=>u!==void 0)})).filter(c=>c.pointList.length!==0);s[0]&&s[0].pointList&&l&&(s[0].pointList=s[0].pointList.map(c=>__spreadProps(__spreadValues({},c),{specialEdge:!0})));let h=[];if(s.length===6&&i===!0){const c=s[0].pointList,u=s[1].pointList;h=buildConvexHull([...c,...u])}return{transferViewData:s,viewRangePointList:h}}function pointMappingLidar2image(e,t,r){var n;const i=isFisheyeCalibValid(t),{P:o,R:l,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,l,f))!=null?n:{};if(!s)return;a=s}const x=e.length/3,p={};for(let s=0;s<x;s++){const h={x:e[s*3],y:e[s*3+1],z:e[s*3+2]};let c;if(i?c=lidar2FisheyeImage(h,t):c=a&&lidar2image({x:e[s*3],y:e[s*3+1],z:e[s*3+2]},a),c){const u=Math.floor(c.x),y=Math.floor(c.y);if(u>r.width||y>r.height||u<0||y<0)continue;p[s]={x:u,y}}}return{pcdMapping:p}}function pointListLidar2Img(e,t,r){var n;if(!t||!r)return;const i=isFisheyeCalibValid(t),{P:o,R:l,T:f}=t;let a;if(i===!1){const{composeMatrix4:s}=(n=transferKitti2Matrix(o,l,f))!=null?n:{};if(!s)return;a=s}const x=[];if(e.forEach(s=>{let h;if(i?h=lidar2FisheyeImage(s,t):h=a&&lidar2image(s,a),h){const{x:c,y:u}=h;x.push({x:c,y:u})}}),x.some(s=>s.x>0&&s.x<r.width&&s.y>0&&s.y<r.height))return x}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=getHighlightIndexByPoints,exports.isFisheyeCalibValid=isFisheyeCalibValid,exports.isInImage=isInImage,exports.isMatrixValid=isMatrixValid,exports.isMatrixValidByArr=isMatrixValidByArr,exports.lidar2FisheyeImage=lidar2FisheyeImage,exports.lidar2image=lidar2image,exports.mergeHighlightList=mergeHighlightList,exports.oCamFisheyeTransfer=oCamFisheyeTransfer,exports.omniCamera11VTransfer=omniCamera11VTransfer,exports.point3DLidar2Image=point3DLidar2Image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.pointListLidar2Img=pointListLidar2Img,exports.pointMappingLidar2image=pointMappingLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const math=require("mathjs");function convertMatrix(t){if(t.length!==1||t[0].length!==3)throw new Error("Input matrix must be a 1x3 or 3x1 matrix");return[[t[0][0]],[t[0][1]],[t[0][2]],[1]]}function normOfRows(t){const o=[];for(let e=0;e<t.length;e++){const n=t[e],s=n[0]*n[0]+n[1]*n[1],r=Math.sqrt(s);o.push(r)}return o}function polyVal(t,o){const e=t.length,n=[];for(let s=0;s<o.length;s++){let r=0;for(let i=0;i<t.length;i++)r=t[e-i-1]+r*o[s];n.push(r)}return n}function fisheyeCameraToImage(t,o,e){const n=math.matrix([[o[0][0],o[0][1]],[o[1][0],o[1][1]]]),s=o[0][2],r=o[1][2],i=e,l=normOfRows(t.toArray().map(p=>p.slice(0,2))),u=math.dotDivide(math.ones(math.matrix(l).size()),l),f=math.atan2(math.multiply(-1,t.subset(math.index(math.range(0,math.matrix(t).size()[0]),2))),l),a=polyVal(i,f);let c=math.ones(2,t.size()[0]);const x=math.multiply(t.subset(math.index(math.range(0,t.size()[0]),0)),u*a),h=math.multiply(t.subset(math.index(math.range(0,t.size()[0]),1)),u*a),m=math.matrix([[x,0],[h,0]]);c=math.subset(m,math.index(math.range(0,m.size()[0]),0));const g=math.matrix([s,r]),y=math.multiply(n,c),d=g.reshape([2,1]);return math.transpose(math.add(y,d)).toArray()}function transformPointCloudToImage(t=[],o,e,n){const s=math.matrix(convertMatrix(t)),r=math.matrix(o),i=math.multiply(r,s);return fisheyeCameraToImage(math.transpose(i),e,n)}exports.transformPointCloudToImage=transformPointCloudToImage;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),pointCloud2DRectOperation=require("./core/toolOperation/pointCloud2DRectOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),segmentByRect=require("./core/toolOperation/segmentByRect.js"),segmentBySAM=require("./core/toolOperation/segmentBySAM.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),EventBus=require("./utils/EventBus.js"),CanvasUtils=require("./utils/tool/CanvasUtils.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),cursorTextClass=require("./core/toolOperation/cursorTextClass.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.PointCloud2DRectOperation=pointCloud2DRectOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.SegmentByRect=segmentByRect,exports.SegmentBySAM=segmentBySAM,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAudioToolName",{enumerable:!0,get:function(){return tool.EAudioToolName}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils.default,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.EventBus=EventBus,exports.CanvasUtils=CanvasUtils,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CursorTextClass=cursorTextClass,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isFisheyeCalibValid=matrix.isFisheyeCalibValid,exports.isInImage=matrix.isInImage,exports.isMatrixValid=matrix.isMatrixValid,exports.isMatrixValidByArr=matrix.isMatrixValidByArr,exports.lidar2FisheyeImage=matrix.lidar2FisheyeImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.oCamFisheyeTransfer=matrix.oCamFisheyeTransfer,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.pointListLidar2Img=matrix.pointListLidar2Img,exports.pointMappingLidar2image=matrix.pointMappingLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),pointCloud2DRectOperation=require("./core/toolOperation/pointCloud2DRectOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),segmentByRect=require("./core/toolOperation/segmentByRect.js"),segmentBySAM=require("./core/toolOperation/segmentBySAM.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),EventBus=require("./utils/EventBus.js"),CanvasUtils=require("./utils/tool/CanvasUtils.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),cursorTextClass=require("./core/toolOperation/cursorTextClass.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.PointCloud2DRectOperation=pointCloud2DRectOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.SegmentByRect=segmentByRect,exports.SegmentBySAM=segmentBySAM,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAudioToolName",{enumerable:!0,get:function(){return tool.EAudioToolName}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils.default,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.EventBus=EventBus,exports.CanvasUtils=CanvasUtils,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CursorTextClass=cursorTextClass,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isFisheyeCalibValid=matrix.isFisheyeCalibValid,exports.isInImage=matrix.isInImage,exports.isMatrixValid=matrix.isMatrixValid,exports.isMatrixValidByArr=matrix.isMatrixValidByArr,exports.lidar2FisheyeImage=matrix.lidar2FisheyeImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.oCamFisheyeTransfer=matrix.oCamFisheyeTransfer,exports.omniCamera11VTransfer=matrix.omniCamera11VTransfer,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.pointListLidar2Img=matrix.pointListLidar2Img,exports.pointMappingLidar2image=matrix.pointMappingLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
|
|
@@ -47,6 +47,7 @@ export declare const isFisheyeCalibValid: (calib: ICalib) => boolean;
|
|
|
47
47
|
* @returns
|
|
48
48
|
*/
|
|
49
49
|
export declare const oCamFisheyeTransfer: (point: I3DSpaceCoord, calib: ICalib) => THREE.Vector4 | undefined;
|
|
50
|
+
export declare const omniCamera11VTransfer: (point: I3DSpaceCoord, calib: ICalib) => THREE.Vector4 | undefined;
|
|
50
51
|
/**
|
|
51
52
|
* Calculate lidar to fisheyeImage.
|
|
52
53
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms a point cloud to 2D image points in a fisheye camera.
|
|
3
|
+
* @param {Array<Array<number>>} pcloud - The point cloud.
|
|
4
|
+
* @param {Array<Array<number>>} lidar2cam - The transformation matrix from LIDAR to camera.
|
|
5
|
+
* @param {Array<Array<number>>} cameraIntrinsic - The camera intrinsic matrix.
|
|
6
|
+
* @param {Array<number>} cameraIntrinsicDist - The camera distortion parameters.
|
|
7
|
+
* @returns {Array<Array<number>>} The corresponding 2D image points.
|
|
8
|
+
*/
|
|
9
|
+
export function transformPointCloudToImage(pcloud: number[][] | undefined, lidar2cam: Array<Array<number>>, cameraIntrinsic: Array<Array<number>>, cameraIntrinsicDist: Array<number>): Array<Array<number>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as a from"three";import{toolStyleConverter as L,PerspectiveShiftUtils as B,EPerspectiveView as C,PointCloudUtils as E,DEFAULT_SPHERE_PARAMS as O}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import R from"../../_virtual/filterBoxWorker.js";import{isInPolygon as H}from"../../utils/tool/polygonTool.js";import k from"../../utils/uuid.js";import A from"../../utils/MathUtils.js";import W from"../../utils/ImgUtils.js";import{PCDLoader as Z}from"./PCDLoader.js";import{OrbitControls as U}from"./OrbitControls.js";import{PointCloudCache as G}from"./cache.js";import{getCuboidFromPointCloudBox as D,getHighlightIndexByPoints as $,mergeHighlightList as Y}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isFisheyeCalibValid,isInImage,isMatrixValid,isMatrixValidByArr,lidar2FisheyeImage,lidar2image,mergeHighlightList,oCamFisheyeTransfer,point3DLidar2Image,pointCloudLidar2image,pointListLidar2Img,pointMappingLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import{PointCloudSegmentOperation as X}from"./segmentation.js";import q from"./store/index.js";import K from"./render/index.js";import Q from"../toolOperation/eventListener.js";import"../../constant/tool.js";import"../scheduler.js";var J=Object.defineProperty,tt=Object.defineProperties,et=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,j=(w,t,e)=>t in w?J(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,b=(w,t)=>{for(var e in t||(t={}))it.call(t,e)&&j(w,e,t[e]);if(_)for(var e of _(t))rt.call(t,e)&&j(w,e,t[e]);return w},P=(w,t)=>tt(w,et(t)),S=(w,t,e)=>new Promise((i,r)=>{var o=d=>{try{s(e.next(d))}catch(n){r(n)}},h=d=>{try{s(e.throw(d))}catch(n){r(n)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,h);s((e=e.apply(w,t)).next())});const nt=30,I=new V({type:"module"});class ot extends Q{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:o="#4C4C4C",config:h,isSegment:s,checkMode:d}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.workerLoading=!1,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(n,l="blue")=>{var c;const u=(c=n.id)!=null?c:k();this.removeObjectByName(u,"sphere");const{radius:m,widthSegments:f,heightSegments:p}=O,{center:g}=n,x=new a.Group,y=new a.SphereGeometry(m,f,p),M=new a.MeshBasicMaterial({color:l}),v=new a.Mesh(y,M);v.position.set(g.x,g.y,g.z),x.add(v),x.name=`sphere${u}`,this.scene.add(x)},this.generateSphere=n=>{const{fill:l}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,l),this.render()},this.generateSpheres=n=>{n.forEach(l=>{const{fill:c}=this.getColorFromConfig(l.attribute);this.addSphereToSense(l,c)}),this.render()},this.addBoxToSense=(n,l=16777215)=>{var c;const u=(c=n.id)!=null?c:k();this.removeObjectByName(u,"box");const{center:m,width:f,height:p,depth:g,rotation:x}=n,y=new a.Group,M=new a.BoxGeometry(f,p,g),v=new a.MeshBasicMaterial({color:"blue"}),z=new a.Mesh(M,v),N=new a.BoxHelper(z,l),F=this.generateBoxArrow(n),T=this.generateBoxTrackID(n);T&&y.add(T),y.add(N),y.add(F),m&&y.position.set(m.x,m.y,m.z),x&&y.rotation.set(0,0,x),y.name=`box${u}`,this.scene.add(y)},this.applyCameraTarget=n=>{if(this.camera.type==="OrthographicCamera"&&n){const l=this.getOrthographicCameraTarget(n);this.updateCameraZoom(n.zoom),this.updateCamera(n.position,l)}},this.initShaderMaterial=()=>({vertexShader:`
|
|
1
|
+
import*as a from"three";import{toolStyleConverter as L,PerspectiveShiftUtils as B,EPerspectiveView as C,PointCloudUtils as E,DEFAULT_SPHERE_PARAMS as O}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import R from"../../_virtual/filterBoxWorker.js";import{isInPolygon as H}from"../../utils/tool/polygonTool.js";import k from"../../utils/uuid.js";import A from"../../utils/MathUtils.js";import W from"../../utils/ImgUtils.js";import{PCDLoader as Z}from"./PCDLoader.js";import{OrbitControls as U}from"./OrbitControls.js";import{PointCloudCache as G}from"./cache.js";import{getCuboidFromPointCloudBox as D,getHighlightIndexByPoints as $,mergeHighlightList as Y}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isFisheyeCalibValid,isInImage,isMatrixValid,isMatrixValidByArr,lidar2FisheyeImage,lidar2image,mergeHighlightList,oCamFisheyeTransfer,omniCamera11VTransfer,point3DLidar2Image,pointCloudLidar2image,pointListLidar2Img,pointMappingLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import{PointCloudSegmentOperation as X}from"./segmentation.js";import q from"./store/index.js";import K from"./render/index.js";import Q from"../toolOperation/eventListener.js";import"../../constant/tool.js";import"../scheduler.js";var J=Object.defineProperty,tt=Object.defineProperties,et=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,j=(w,t,e)=>t in w?J(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,b=(w,t)=>{for(var e in t||(t={}))it.call(t,e)&&j(w,e,t[e]);if(_)for(var e of _(t))rt.call(t,e)&&j(w,e,t[e]);return w},P=(w,t)=>tt(w,et(t)),S=(w,t,e)=>new Promise((i,r)=>{var o=d=>{try{s(e.next(d))}catch(n){r(n)}},h=d=>{try{s(e.throw(d))}catch(n){r(n)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,h);s((e=e.apply(w,t)).next())});const nt=30,I=new V({type:"module"});class ot extends Q{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:o="#4C4C4C",config:h,isSegment:s,checkMode:d}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.workerLoading=!1,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(n,l="blue")=>{var c;const u=(c=n.id)!=null?c:k();this.removeObjectByName(u,"sphere");const{radius:m,widthSegments:f,heightSegments:p}=O,{center:g}=n,x=new a.Group,y=new a.SphereGeometry(m,f,p),M=new a.MeshBasicMaterial({color:l}),v=new a.Mesh(y,M);v.position.set(g.x,g.y,g.z),x.add(v),x.name=`sphere${u}`,this.scene.add(x)},this.generateSphere=n=>{const{fill:l}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,l),this.render()},this.generateSpheres=n=>{n.forEach(l=>{const{fill:c}=this.getColorFromConfig(l.attribute);this.addSphereToSense(l,c)}),this.render()},this.addBoxToSense=(n,l=16777215)=>{var c;const u=(c=n.id)!=null?c:k();this.removeObjectByName(u,"box");const{center:m,width:f,height:p,depth:g,rotation:x}=n,y=new a.Group,M=new a.BoxGeometry(f,p,g),v=new a.MeshBasicMaterial({color:"blue"}),z=new a.Mesh(M,v),N=new a.BoxHelper(z,l),F=this.generateBoxArrow(n),T=this.generateBoxTrackID(n);T&&y.add(T),y.add(N),y.add(F),m&&y.position.set(m.x,m.y,m.z),x&&y.rotation.set(0,0,x),y.name=`box${u}`,this.scene.add(y)},this.applyCameraTarget=n=>{if(this.camera.type==="OrthographicCamera"&&n){const l=this.getOrthographicCameraTarget(n);this.updateCameraZoom(n.zoom),this.updateCamera(n.position,l)}},this.initShaderMaterial=()=>({vertexShader:`
|
|
2
2
|
attribute vec3 dimensions;
|
|
3
3
|
varying vec3 vDimensions;
|
|
4
4
|
uniform float pointSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as p from"three";import{MatrixUtils as M,ECameraType as _,PointCloudUtils as K}from"@labelbee/lb-utils";import A from"../../utils/uuid.js";import{transformPointCloudToImage as k}from"./omniCamera.js";var B=Object.defineProperty,N=Object.defineProperties,U=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,T=Math.pow,L=(r,t,e)=>t in r?B(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,V=(r,t)=>{for(var e in t||(t={}))Z.call(t,e)&&L(r,e,t[e]);if(I)for(var e of I(t))q.call(t,e)&&L(r,e,t[e]);return r},F=(r,t)=>N(r,U(t));function g(r){return new p.Matrix4().set(...r)}function v(r,t,e){try{const n=M.transferMatrix34FromKitti2Three(r),s=M.transferMatrix33FromKitti2Three(t),o=M.transferMatrix34FromKitti2Three(e),c=g(n),f=g(s),a=g(o);return{composeMatrix4:a.clone().premultiply(f).premultiply(c),PM:c,RM:f,TM:a}}catch(n){console.error(n)}}function C(r,t,e){var n;const s=new p.Vector3(r.x,r.y,(n=r==null?void 0:r.z)!=null?n:1),o=new p.Matrix4().makeRotationZ(e),c=new p.Matrix4().makeTranslation(t.x,t.y,t.z),f=new p.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return s.clone().applyMatrix4(f).applyMatrix4(o).applyMatrix4(c)}function O(r,t,e){return!(r.length!==t||r.some(n=>n.length!==e))}const z=(r,t)=>t.some(e=>O(r,e[0],e[1])),m=r=>{var t;return!!(((t=r.fisheyeDistortion)==null?void 0:t.length)>0&&z(r.P,[[3,4],[4,4]])&&z(r.T,[[3,4],[4,4]]))},R=(r,t)=>{if(m(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:e,fisheyeDistortion:n,T:s}=t,o=new p.Vector4(r.x,r.y,r.z),c=g(M.transferMatrix34FromKitti2Three(s)),f=g(M.transferMatrix34FromKitti2Three(e)),a=o.applyMatrix4(c),h=T(T(a.x,2)+T(a.y,2),.5),y=Math.atan(a.z/h),i=n.reduce((l,u,d)=>l+u*T(y,d),0);return a.x=a.x/h*i,a.y=a.y/h*i,a.z=1,a.applyMatrix4(f)},E=(r,t)=>{if(m(t)===!1){console.error("Error Calib, it need fisheye calib");return}const{P:e,fisheyeDistortion:n,T:s}=t,o=k([[r.x,r.y,r.z]],s,e,n);return new p.Vector4(o[0][0],o[0][1],1)},G=(r,t)=>{const e=r.length;let n=0;const s=[];for(let o=0;o<r.length;o++)s.push(r[e-o-1]+n*t),n=r[e-o-1]+n*t;return n},J=(r,t)=>{const{P:e,fisheyeDistortion:n}=t,{x:s,y:o,z:c}=r,f=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],a=e[0][2],h=e[1][2],y=1/Math.hypot(s,o),i=[],x=Math.atan2(Math.hypot(s,o),c),l=G(n,x);return i[0]=s*y*l,i[1]=o*y*l,{x:f[0][0]*i[0]+f[0][1]*i[1]+a,y:f[1][0]*i[0]+f[1][1]*i[1]+h}},P=(r,t)=>{if(m(t)===!1){console.error("Error Calib, it need fisheye calib");return}if((t==null?void 0:t.cameraType)===_.OmniCamera)return R(r,t);if((t==null?void 0:t.cameraType)===_.KannalaBrandt)return J(r,t);if((t==null?void 0:t.cameraType)===_.OmniCamera11V)return E(r,t)};function w(r,t){const n=new p.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(n.z<0)return;const s=1/n.z,o=new p.Matrix4().set(s,0,0,0,0,s,0,0,0,0,s,0,0,0,0,1);return n.applyMatrix4(o)}function Q(r){const{center:t,width:e,height:n,depth:s,rotation:o}=r,c=[{x:t.x+e/2,y:t.y-n/2},{x:t.x+e/2,y:t.y+n/2},{x:t.x-e/2,y:t.y+n/2},{x:t.x-e/2,y:t.y-n/2}].map(h=>{const y=C(h,t,o);return{x:y.x,y:y.y}}),f=t.z+s/2,a=t.z-s/2;return F(V({},r),{polygonPointList:c,zMax:f,zMin:a})}function W(r){const t=r.slice();return t.sort((e,n)=>e.x===n.x?n.y-e.y:e.x-n.x),t}function D(r,t,e){const n=t.x-r.x,s=t.y-r.y,o=e.x-r.x,c=e.y-r.y;return n*c-o*s}function X(r){const t=W(r),e=[];for(let o=0;o<t.length;o++){for(;e.length>=2&&D(e[e.length-2],e[e.length-1],t[o])<=0;)e.pop();e.push(t[o])}const n=[];for(let o=t.length-1;o>=0;o--){for(;n.length>=2&&D(n[n.length-2],n[n.length-1],t[o])<=0;)n.pop();n.push(t[o])}return e.pop(),n.pop(),e.concat(n)}const H=(r,t)=>{var e;if(m(t))return P(r,t);const{P:n,R:s,T:o}=t,{composeMatrix4:c}=(e=v(n,s,o))!=null?e:{};if(!!c)return w(r,c)},j=({point:r,calib:t,width:e,height:n})=>{if(!t)return!1;const s=H(r,t);return s?s.x>=0&&s.x<=e&&s.y>=0&&s.y<=n:!1},Y=({points:r,calib:t,width:e,height:n})=>{const s=[];for(let o=0;o<r.length;o+=3){const c=r[o],f=r[o+1],a=r[o+2];j({point:{x:c,y:f,z:a},calib:t,width:e,height:n})?s.push(1):s.push(0)}return s},$=r=>{if(r.length===0)return[];const t=[];for(let e=0;e<r[0].length;e++){for(let n=0;n<r.length;n++)if(r[n][e]===1){t.push(1);break}t.length===e&&t.push(0)}return t};function S(r,t,e={createRange:!1}){var n;if(!t)return{transferViewData:[],viewRangePointList:[]};const{createRange:s}=e,o=K.getAllViewData(r),c=m(t),{P:f,R:a,T:h}=t;let y;if(c===!1){const{composeMatrix4:l}=(n=v(f,a,h))!=null?n:{};if(!l)return;y=l}const i=o.map(l=>({type:l.type,pointList:l.pointList.map(u=>C(u,r.center,r.rotation)).map(u=>c?P(u,t):y&&w(u,y)).map(u=>{if(!!u)return{id:A(),x:u==null?void 0:u.x,y:u==null?void 0:u.y}}).filter(u=>u!==void 0)})).filter(l=>l.pointList.length!==0);i[0]&&i[0].pointList&&c&&(i[0].pointList=i[0].pointList.map(l=>F(V({},l),{specialEdge:!0})));let x=[];if(i.length===6&&s===!0){const l=i[0].pointList,u=i[1].pointList;x=X([...l,...u])}return{transferViewData:i,viewRangePointList:x}}function b(r,t,e){var n;const s=m(t),{P:o,R:c,T:f}=t;let a;if(s===!1){const{composeMatrix4:i}=(n=v(o,c,f))!=null?n:{};if(!i)return;a=i}const h=r.length/3,y={};for(let i=0;i<h;i++){const x={x:r[i*3],y:r[i*3+1],z:r[i*3+2]};let l;if(s?l=P(x,t):l=a&&w({x:r[i*3],y:r[i*3+1],z:r[i*3+2]},a),l){const u=Math.floor(l.x),d=Math.floor(l.y);if(u>e.width||d>e.height||u<0||d<0)continue;y[i]={x:u,y:d}}}return{pcdMapping:y}}function tt(r,t,e){var n;if(!t||!e)return;const s=m(t),{P:o,R:c,T:f}=t;let a;if(s===!1){const{composeMatrix4:i}=(n=v(o,c,f))!=null?n:{};if(!i)return;a=i}const h=[];if(r.forEach(i=>{let x;if(s?x=P(i,t):x=a&&w(i,a),x){const{x:l,y:u}=x;h.push({x:l,y:u})}}),h.some(i=>i.x>0&&i.x<e.width&&i.y>0&&i.y<e.height))return h}export{g as createThreeMatrix4,Q as getCuboidFromPointCloudBox,Y as getHighlightIndexByPoints,m as isFisheyeCalibValid,j as isInImage,O as isMatrixValid,z as isMatrixValidByArr,P as lidar2FisheyeImage,w as lidar2image,$ as mergeHighlightList,R as oCamFisheyeTransfer,E as omniCamera11VTransfer,H as point3DLidar2Image,S as pointCloudLidar2image,tt as pointListLidar2Img,b as pointMappingLidar2image,C as rotatePoint,v as transferKitti2Matrix};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=require("mathjs");function P(n){if(n.length!==1||n[0].length!==3)throw new Error("Input matrix must be a 1x3 or 3x1 matrix");return[[n[0][0]],[n[0][1]],[n[0][2]],[1]]}function b(n){const o=[];for(let s=0;s<n.length;s++){const e=n[s],r=e[0]*e[0]+e[1]*e[1],i=Math.sqrt(r);o.push(i)}return o}function v(n,o){const s=n.length,e=[];for(let r=0;r<o.length;r++){let i=0;for(let l=0;l<n.length;l++)i=n[s-l-1]+i*o[r];e.push(i)}return e}function w(n,o,s){const e=t.matrix([[o[0][0],o[0][1]],[o[1][0],o[1][1]]]),r=o[0][2],i=o[1][2],l=s,u=b(n.toArray().map(z=>z.slice(0,2))),a=t.dotDivide(t.ones(t.matrix(u).size()),u),h=t.atan2(t.multiply(-1,n.subset(t.index(t.range(0,t.matrix(n).size()[0]),2))),u),c=v(l,h);let m=t.ones(2,n.size()[0]);const x=t.multiply(n.subset(t.index(t.range(0,n.size()[0]),0)),a*c),g=t.multiply(n.subset(t.index(t.range(0,n.size()[0]),1)),a*c),f=t.matrix([[x,0],[g,0]]);m=t.subset(f,t.index(t.range(0,f.size()[0]),0));const y=t.matrix([r,i]),d=t.multiply(e,m),p=y.reshape([2,1]);return t.transpose(t.add(d,p)).toArray()}function q(n=[],o,s,e){const r=t.matrix(P(n)),i=t.matrix(o),l=t.multiply(i,r);return w(t.transpose(l),s,e)}export{q as transformPointCloudToImage};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{default as PointCloud2DRectOperation}from"./core/toolOperation/pointCloud2DRectOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";export{default as SegmentByRect}from"./core/toolOperation/segmentByRect.js";export{default as SegmentBySAM}from"./core/toolOperation/segmentBySAM.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAudioToolName,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as EventBus}from"./utils/EventBus.js";export{default as CanvasUtils}from"./utils/tool/CanvasUtils.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{default as CursorTextClass}from"./core/toolOperation/cursorTextClass.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isFisheyeCalibValid,isInImage,isMatrixValid,isMatrixValidByArr,lidar2FisheyeImage,lidar2image,mergeHighlightList,oCamFisheyeTransfer,point3DLidar2Image,pointCloudLidar2image,pointListLidar2Img,pointMappingLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
|
|
1
|
+
export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{default as PointCloud2DRectOperation}from"./core/toolOperation/pointCloud2DRectOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";export{default as SegmentByRect}from"./core/toolOperation/segmentByRect.js";export{default as SegmentBySAM}from"./core/toolOperation/segmentBySAM.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAudioToolName,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as EventBus}from"./utils/EventBus.js";export{default as CanvasUtils}from"./utils/tool/CanvasUtils.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{default as CursorTextClass}from"./core/toolOperation/cursorTextClass.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isFisheyeCalibValid,isInImage,isMatrixValid,isMatrixValidByArr,lidar2FisheyeImage,lidar2image,mergeHighlightList,oCamFisheyeTransfer,omniCamera11VTransfer,point3DLidar2Image,pointCloudLidar2image,pointListLidar2Img,pointMappingLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-annotation",
|
|
3
|
-
"version": "1.27.0-alpha.
|
|
3
|
+
"version": "1.27.0-alpha.5",
|
|
4
4
|
"description": "Annotation tool collection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotation",
|
|
@@ -94,10 +94,11 @@
|
|
|
94
94
|
"typescript": "^4.2.3"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@labelbee/lb-utils": "1.19.0-alpha.
|
|
97
|
+
"@labelbee/lb-utils": "1.19.0-alpha.2",
|
|
98
98
|
"@turf/turf": "5.1.6",
|
|
99
99
|
"color-rgba": "^2.3.0",
|
|
100
100
|
"lodash": "^4.17.20",
|
|
101
|
+
"mathjs": "11.8.1",
|
|
101
102
|
"three": ">=0.141.0"
|
|
102
103
|
}
|
|
103
104
|
}
|