@labelbee/lb-annotation 1.15.0-alpha.5 → 1.15.0

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.
@@ -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(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return r[e]}})}}),t.default=r,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,__defNormalProp=(r,t,e)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues=(r,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(r,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(r,e,t[e]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));function createThreeMatrix4(r){return new THREE__namespace.Matrix4().set(...r)}function transferKitti2Matrix(r,t,e){const i=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),n=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),l=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),o=createThreeMatrix4(i),s=createThreeMatrix4(n),u=createThreeMatrix4(l);return{composeMatrix4:u.clone().premultiply(s).premultiply(o),PM:o,RM:s,TM:u}}function rotatePoint(r,t,e){var i;const n=new THREE__namespace.Vector3(r.x,r.y,(i=r==null?void 0:r.z)!=null?i:1),l=new THREE__namespace.Matrix4().makeRotationZ(e),o=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),s=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return n.clone().applyMatrix4(s).applyMatrix4(l).applyMatrix4(o)}function lidar2image(r,t){const i=new THREE__namespace.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(i.z<0)return;const n=1/i.z,l=new THREE__namespace.Matrix4().set(n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1);return i.applyMatrix4(l)}function getCuboidFromPointCloudBox(r){const{center:t,width:e,height:i,depth:n,rotation:l}=r,o=[{x:t.x+e/2,y:t.y-i/2},{x:t.x+e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y-i/2}].map(c=>{const a=rotatePoint(c,t,l);return{x:a.x,y:a.y}}),s=t.z+n/2,u=t.z-n/2;return __spreadProps(__spreadValues({},r),{polygonPointList:o,zMax:s,zMin:u})}function orientation(r,t,e){const i=(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y);return i===0?0:i>0?1:2}function convexHull(r){const t=r.length;if(t<3)return[];const e=[];let i=0;for(let o=1;o<t;o++)r[o].x<r[i].x&&(i=o);let n=i,l;do{e.push(r[n]),l=(n+1)%t;for(let o=0;o<t;o++)orientation(r[n],r[o],r[l])===2&&(l=o);n=l}while(n!==i);return e}function pointCloudLidar2image(r,t){const e=lbUtils.PointCloudUtils.getAllViewData(r),{P:i,R:n,T:l}=t,{composeMatrix4:o}=transferKitti2Matrix(i,n,l),s=e.map(c=>({type:c.type,pointList:c.pointList.map(a=>rotatePoint(a,r.center,r.rotation)).map(a=>lidar2image(a,o)).map(a=>{if(!!a)return{id:uuid(),x:a==null?void 0:a.x,y:a==null?void 0:a.y}}).filter(a=>a!==void 0)})).filter(c=>c.pointList.length!==0);let u=[];if(s.length===6){const c=s[0].pointList,a=s[1].pointList;u=convexHull([...c,...a])}return{transferViewData:s,viewRangePointList:u}}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.lidar2image=lidar2image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
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(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return r[e]}})}}),t.default=r,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,__defNormalProp=(r,t,e)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues=(r,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(r,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(r,e,t[e]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));function createThreeMatrix4(r){return new THREE__namespace.Matrix4().set(...r)}function transferKitti2Matrix(r,t,e){const i=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),n=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),a=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),o=createThreeMatrix4(i),s=createThreeMatrix4(n),c=createThreeMatrix4(a);return{composeMatrix4:c.clone().premultiply(s).premultiply(o),PM:o,RM:s,TM:c}}function rotatePoint(r,t,e){var i;const n=new THREE__namespace.Vector3(r.x,r.y,(i=r==null?void 0:r.z)!=null?i:1),a=new THREE__namespace.Matrix4().makeRotationZ(e),o=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),s=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return n.clone().applyMatrix4(s).applyMatrix4(a).applyMatrix4(o)}function lidar2image(r,t){const i=new THREE__namespace.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(i.z<0)return;const n=1/i.z,a=new THREE__namespace.Matrix4().set(n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1);return i.applyMatrix4(a)}function getCuboidFromPointCloudBox(r){const{center:t,width:e,height:i,depth:n,rotation:a}=r,o=[{x:t.x+e/2,y:t.y-i/2},{x:t.x+e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y-i/2}].map(u=>{const x=rotatePoint(u,t,a);return{x:x.x,y:x.y}}),s=t.z+n/2,c=t.z-n/2;return __spreadProps(__spreadValues({},r),{polygonPointList:o,zMax:s,zMin:c})}function orientation(r,t,e){const i=(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y);return i===0?0:i>0?1:2}function convexHull(r){const t=r.length;if(t<3)return[];const e=[];let i=0;for(let o=1;o<t;o++)r[o].x<r[i].x&&(i=o);let n=i,a;do{e.push(r[n]),a=(n+1)%t;for(let o=0;o<t;o++)orientation(r[n],r[o],r[a])===2&&(a=o);n=a}while(n!==i);return e}function pointCloudLidar2image(r,t,e={createRange:!1}){const{createRange:i}=e,n=lbUtils.PointCloudUtils.getAllViewData(r),{P:a,R:o,T:s}=t,{composeMatrix4:c}=transferKitti2Matrix(a,o,s),u=n.map(p=>({type:p.type,pointList:p.pointList.map(l=>rotatePoint(l,r.center,r.rotation)).map(l=>lidar2image(l,c)).map(l=>{if(!!l)return{id:uuid(),x:l==null?void 0:l.x,y:l==null?void 0:l.y}}).filter(l=>l!==void 0)})).filter(p=>p.pointList.length!==0);let x=[];if(u.length===6&&i===!0){const p=u[0].pointList,l=u[1].pointList;x=convexHull([...p,...l])}return{transferViewData:u,viewRangePointList:x}}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.lidar2image=lidar2image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
@@ -53,6 +53,8 @@ export declare function pointCloudLidar2image(boxParams: IPointCloudBox, cameraM
53
53
  P: [TMatrix14Tuple, TMatrix14Tuple, TMatrix14Tuple];
54
54
  R: [TMatrix13Tuple, TMatrix13Tuple, TMatrix13Tuple];
55
55
  T: [TMatrix14Tuple, TMatrix14Tuple, TMatrix14Tuple];
56
+ }, options?: {
57
+ createRange: boolean;
56
58
  }): {
57
59
  transferViewData: {
58
60
  type: string;
@@ -1 +1 @@
1
- import*as p from"three";import{MatrixUtils as f,PointCloudUtils as w}from"@labelbee/lb-utils";import _ from"../../utils/uuid.js";var h=Object.defineProperty,g=Object.defineProperties,P=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,M=(r,t,e)=>t in r?h(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,T=(r,t)=>{for(var e in t||(t={}))z.call(t,e)&&M(r,e,t[e]);if(m)for(var e of m(t))O.call(t,e)&&M(r,e,t[e]);return r},L=(r,t)=>g(r,P(t));function x(r){return new p.Matrix4().set(...r)}function d(r,t,e){const o=f.transferMatrix34FromKitti2Three(r),n=f.transferMatrix33FromKitti2Three(t),l=f.transferMatrix34FromKitti2Three(e),i=x(o),s=x(n),u=x(l);return{composeMatrix4:u.clone().premultiply(s).premultiply(i),PM:i,RM:s,TM:u}}function y(r,t,e){var o;const n=new p.Vector3(r.x,r.y,(o=r==null?void 0:r.z)!=null?o:1),l=new p.Matrix4().makeRotationZ(e),i=new p.Matrix4().makeTranslation(t.x,t.y,t.z),s=new p.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return n.clone().applyMatrix4(s).applyMatrix4(l).applyMatrix4(i)}function v(r,t){const o=new p.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(o.z<0)return;const n=1/o.z,l=new p.Matrix4().set(n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1);return o.applyMatrix4(l)}function V(r){const{center:t,width:e,height:o,depth:n,rotation:l}=r,i=[{x:t.x+e/2,y:t.y-o/2},{x:t.x+e/2,y:t.y+o/2},{x:t.x-e/2,y:t.y+o/2},{x:t.x-e/2,y:t.y-o/2}].map(c=>{const a=y(c,t,l);return{x:a.x,y:a.y}}),s=t.z+n/2,u=t.z-n/2;return L(T({},r),{polygonPointList:i,zMax:s,zMin:u})}function R(r,t,e){const o=(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y);return o===0?0:o>0?1:2}function b(r){const t=r.length;if(t<3)return[];const e=[];let o=0;for(let i=1;i<t;i++)r[i].x<r[o].x&&(o=i);let n=o,l;do{e.push(r[n]),l=(n+1)%t;for(let i=0;i<t;i++)R(r[n],r[i],r[l])===2&&(l=i);n=l}while(n!==o);return e}function j(r,t){const e=w.getAllViewData(r),{P:o,R:n,T:l}=t,{composeMatrix4:i}=d(o,n,l),s=e.map(c=>({type:c.type,pointList:c.pointList.map(a=>y(a,r.center,r.rotation)).map(a=>v(a,i)).map(a=>{if(!!a)return{id:_(),x:a==null?void 0:a.x,y:a==null?void 0:a.y}}).filter(a=>a!==void 0)})).filter(c=>c.pointList.length!==0);let u=[];if(s.length===6){const c=s[0].pointList,a=s[1].pointList;u=b([...c,...a])}return{transferViewData:s,viewRangePointList:u}}export{x as createThreeMatrix4,V as getCuboidFromPointCloudBox,v as lidar2image,j as pointCloudLidar2image,y as rotatePoint,d as transferKitti2Matrix};
1
+ import*as s from"three";import{MatrixUtils as m,PointCloudUtils as g}from"@labelbee/lb-utils";import h from"../../utils/uuid.js";var P=Object.defineProperty,z=Object.defineProperties,O=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,v=(r,t,e)=>t in r?P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,R=(r,t)=>{for(var e in t||(t={}))T.call(t,e)&&v(r,e,t[e]);if(d)for(var e of d(t))L.call(t,e)&&v(r,e,t[e]);return r},V=(r,t)=>z(r,O(t));function y(r){return new s.Matrix4().set(...r)}function w(r,t,e){const n=m.transferMatrix34FromKitti2Three(r),o=m.transferMatrix33FromKitti2Three(t),a=m.transferMatrix34FromKitti2Three(e),i=y(n),c=y(o),u=y(a);return{composeMatrix4:u.clone().premultiply(c).premultiply(i),PM:i,RM:c,TM:u}}function M(r,t,e){var n;const o=new s.Vector3(r.x,r.y,(n=r==null?void 0:r.z)!=null?n:1),a=new s.Matrix4().makeRotationZ(e),i=new s.Matrix4().makeTranslation(t.x,t.y,t.z),c=new s.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return o.clone().applyMatrix4(c).applyMatrix4(a).applyMatrix4(i)}function _(r,t){const n=new s.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(n.z<0)return;const o=1/n.z,a=new s.Matrix4().set(o,0,0,0,0,o,0,0,0,0,o,0,0,0,0,1);return n.applyMatrix4(a)}function b(r){const{center:t,width:e,height:n,depth:o,rotation:a}=r,i=[{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(f=>{const x=M(f,t,a);return{x:x.x,y:x.y}}),c=t.z+o/2,u=t.z-o/2;return V(R({},r),{polygonPointList:i,zMax:c,zMin:u})}function j(r,t,e){const n=(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y);return n===0?0:n>0?1:2}function F(r){const t=r.length;if(t<3)return[];const e=[];let n=0;for(let i=1;i<t;i++)r[i].x<r[n].x&&(n=i);let o=n,a;do{e.push(r[o]),a=(o+1)%t;for(let i=0;i<t;i++)j(r[o],r[i],r[a])===2&&(a=i);o=a}while(o!==n);return e}function A(r,t,e={createRange:!1}){const{createRange:n}=e,o=g.getAllViewData(r),{P:a,R:i,T:c}=t,{composeMatrix4:u}=w(a,i,c),f=o.map(p=>({type:p.type,pointList:p.pointList.map(l=>M(l,r.center,r.rotation)).map(l=>_(l,u)).map(l=>{if(!!l)return{id:h(),x:l==null?void 0:l.x,y:l==null?void 0:l.y}}).filter(l=>l!==void 0)})).filter(p=>p.pointList.length!==0);let x=[];if(f.length===6&&n===!0){const p=f[0].pointList,l=f[1].pointList;x=F([...p,...l])}return{transferViewData:f,viewRangePointList:x}}export{y as createThreeMatrix4,b as getCuboidFromPointCloudBox,_ as lidar2image,A as pointCloudLidar2image,M as rotatePoint,w as transferKitti2Matrix};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-annotation",
3
- "version": "1.15.0-alpha.5",
3
+ "version": "1.15.0",
4
4
  "description": "Annotation tool collection",
5
5
  "keywords": [
6
6
  "annotation",
@@ -94,7 +94,7 @@
94
94
  "typescript": "^4.2.3"
95
95
  },
96
96
  "dependencies": {
97
- "@labelbee/lb-utils": "1.7.1-alpha.2",
97
+ "@labelbee/lb-utils": "1.7.1",
98
98
  "@turf/turf": "5.1.6",
99
99
  "color-rgba": "^2.3.0",
100
100
  "lodash": "^4.17.20",