@eyepop.ai/eyepop 3.18.0 → 3.19.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.
@@ -12669,6 +12669,97 @@ var DataEndpoint = class extends Endpoint {
12669
12669
  }
12670
12670
  };
12671
12671
 
12672
+ // depth.ts
12673
+ var isLittleEndianPlatform = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
12674
+ function base64ToBytes(base64) {
12675
+ if (typeof Buffer !== "undefined") {
12676
+ const buffer = Buffer.from(base64, "base64");
12677
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
12678
+ }
12679
+ const binary = atob(base64);
12680
+ const bytes = new Uint8Array(binary.length);
12681
+ for (let i = 0; i < binary.length; i++) {
12682
+ bytes[i] = binary.charCodeAt(i);
12683
+ }
12684
+ return bytes;
12685
+ }
12686
+ var DepthMap = class {
12687
+ constructor(width, height, values) {
12688
+ this.width = width;
12689
+ this.height = height;
12690
+ this.values = values;
12691
+ }
12692
+ /**
12693
+ * The depth value at map pixel (x, y), or - when sourceWidth/sourceHeight
12694
+ * are given - at source frame coordinate (x, y) mapped proportionally.
12695
+ * Returns +Infinity for sky pixels.
12696
+ */
12697
+ at(x, y, sourceWidth, sourceHeight) {
12698
+ let mapX = x;
12699
+ let mapY = y;
12700
+ if (sourceWidth && sourceHeight) {
12701
+ mapX = x * this.width / sourceWidth;
12702
+ mapY = y * this.height / sourceHeight;
12703
+ }
12704
+ const clampedX = Math.min(Math.max(Math.floor(mapX), 0), this.width - 1);
12705
+ const clampedY = Math.min(Math.max(Math.floor(mapY), 0), this.height - 1);
12706
+ return this.values[clampedY * this.width + clampedX];
12707
+ }
12708
+ isSky(x, y, sourceWidth, sourceHeight) {
12709
+ return this.at(x, y, sourceWidth, sourceHeight) === Number.POSITIVE_INFINITY;
12710
+ }
12711
+ /** The smallest finite depth value, or undefined if the whole map is sky. */
12712
+ get finiteMin() {
12713
+ this.computeFiniteRange();
12714
+ return this._finiteMin;
12715
+ }
12716
+ /** The largest finite depth value, or undefined if the whole map is sky. */
12717
+ get finiteMax() {
12718
+ this.computeFiniteRange();
12719
+ return this._finiteMax;
12720
+ }
12721
+ computeFiniteRange() {
12722
+ if (this._finiteMin !== void 0 || this._finiteMax !== void 0) {
12723
+ return;
12724
+ }
12725
+ let min = Number.POSITIVE_INFINITY;
12726
+ let max = Number.NEGATIVE_INFINITY;
12727
+ for (let i = 0; i < this.values.length; i++) {
12728
+ const value = this.values[i];
12729
+ if (Number.isFinite(value)) {
12730
+ if (value < min) min = value;
12731
+ if (value > max) max = value;
12732
+ }
12733
+ }
12734
+ if (max >= min) {
12735
+ this._finiteMin = min;
12736
+ this._finiteMax = max;
12737
+ }
12738
+ }
12739
+ };
12740
+ function decodeDepthMap(depth) {
12741
+ if (!Number.isSafeInteger(depth.width) || depth.width <= 0 || !Number.isSafeInteger(depth.height) || depth.height <= 0 || !Number.isSafeInteger(depth.width * depth.height * 4)) {
12742
+ throw new Error(`invalid depth dimensions: ${depth.width}x${depth.height}`);
12743
+ }
12744
+ const bytes = base64ToBytes(depth.values);
12745
+ const count = depth.width * depth.height;
12746
+ if (bytes.byteLength !== count * 4) {
12747
+ throw new Error(`depth values hold ${bytes.byteLength} bytes, expected ${count * 4} for ${depth.width}x${depth.height} float32`);
12748
+ }
12749
+ let values;
12750
+ if (isLittleEndianPlatform) {
12751
+ const aligned = new Uint8Array(bytes);
12752
+ values = new Float32Array(aligned.buffer, 0, count);
12753
+ } else {
12754
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
12755
+ values = new Float32Array(count);
12756
+ for (let i = 0; i < count; i++) {
12757
+ values[i] = view.getFloat32(i * 4, true);
12758
+ }
12759
+ }
12760
+ return new DepthMap(depth.width, depth.height, values);
12761
+ }
12762
+
12672
12763
  // worker/webrtc_whep.ts
12673
12764
  var WebrtcWhep = class extends WebrtcBase {
12674
12765
  constructor(ingressId, getSession, client, requestLogger) {
@@ -12902,6 +12993,7 @@ export {
12902
12993
  DEFAULT_PREDICTION_VERSION,
12903
12994
  DataApiType,
12904
12995
  DataEndpoint,
12996
+ DepthMap,
12905
12997
  Endpoint,
12906
12998
  EndpointState,
12907
12999
  EvaluationStatus,
@@ -12942,6 +13034,7 @@ export {
12942
13034
  WorkflowPhase,
12943
13035
  accessTokenCredential,
12944
13036
  apiKeyCredential,
13037
+ decodeDepthMap,
12945
13038
  index_default as default,
12946
13039
  encodeMultipartFormData,
12947
13040
  getBaseUrl,