@lumy-pack/scene-sieve 0.0.3 → 0.0.4

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/cli.mjs CHANGED
@@ -69,7 +69,7 @@ var DBSCAN_MIN_PTS = 4;
69
69
  var IOU_THRESHOLD = 0.9;
70
70
  var DECAY_LAMBDA = 0.95;
71
71
  var ANIMATION_FRAME_THRESHOLD = 5;
72
- var MATCH_DISTANCE_THRESHOLD = 0.75;
72
+ var MATCH_DISTANCE_THRESHOLD = 0.25;
73
73
  var PIXELDIFF_GAUSSIAN_KERNEL = 3;
74
74
  var PIXELDIFF_BINARY_THRESHOLD = 30;
75
75
  var PIXELDIFF_CONTOUR_MIN_AREA = 100;
@@ -182,7 +182,7 @@ async function ensureOpenCV() {
182
182
  async function preprocessFrame(framePath, scale) {
183
183
  const { data, info } = await sharp(framePath).resize({ width: scale, withoutEnlargement: true }).grayscale().blur(1).raw().toBuffer({ resolveWithObject: true });
184
184
  return {
185
- data: new Uint8Array(data.buffer),
185
+ data: new Uint8Array(data.buffer, data.byteOffset, data.byteLength),
186
186
  width: info.width,
187
187
  height: info.height
188
188
  };
@@ -263,16 +263,11 @@ var IoUTracker = class {
263
263
  }
264
264
  };
265
265
  async function computeAKAZEDiff(cvLib, frame1, frame2) {
266
- const mat1 = cvLib.matFromImageData({
267
- data: frame1.data,
268
- width: frame1.width,
269
- height: frame1.height
270
- });
271
- const mat2 = cvLib.matFromImageData({
272
- data: frame2.data,
273
- width: frame2.width,
274
- height: frame2.height
275
- });
266
+ const cv = cvLib;
267
+ const mat1 = new cv.Mat(frame1.height, frame1.width, cv.CV_8UC1);
268
+ mat1.data.set(frame1.data);
269
+ const mat2 = new cv.Mat(frame2.height, frame2.width, cv.CV_8UC1);
270
+ mat2.data.set(frame2.data);
276
271
  const kp1 = new cvLib.KeyPointVector();
277
272
  const kp2 = new cvLib.KeyPointVector();
278
273
  const desc1 = new cvLib.Mat();
@@ -670,6 +665,7 @@ async function finalizeOutput(ctx, selectedFrames) {
670
665
  outputFiles.push(join3(outputPath, destName));
671
666
  }
672
667
  await ensureDir(join3(outputPath, ".."));
668
+ await rm(outputPath, { recursive: true, force: true });
673
669
  await rename(stagingDir, outputPath);
674
670
  return outputFiles;
675
671
  }
@@ -18,7 +18,7 @@ export declare const DBSCAN_MIN_PTS = 4;
18
18
  export declare const IOU_THRESHOLD = 0.9;
19
19
  export declare const DECAY_LAMBDA = 0.95;
20
20
  export declare const ANIMATION_FRAME_THRESHOLD = 5;
21
- export declare const MATCH_DISTANCE_THRESHOLD = 0.75;
21
+ export declare const MATCH_DISTANCE_THRESHOLD = 0.25;
22
22
  export declare const PIXELDIFF_GAUSSIAN_KERNEL = 3;
23
23
  export declare const PIXELDIFF_BINARY_THRESHOLD = 30;
24
24
  export declare const PIXELDIFF_CONTOUR_MIN_AREA = 100;
package/dist/index.cjs CHANGED
@@ -103,7 +103,7 @@ var DBSCAN_MIN_PTS = 4;
103
103
  var IOU_THRESHOLD = 0.9;
104
104
  var DECAY_LAMBDA = 0.95;
105
105
  var ANIMATION_FRAME_THRESHOLD = 5;
106
- var MATCH_DISTANCE_THRESHOLD = 0.75;
106
+ var MATCH_DISTANCE_THRESHOLD = 0.25;
107
107
  var PIXELDIFF_GAUSSIAN_KERNEL = 3;
108
108
  var PIXELDIFF_BINARY_THRESHOLD = 30;
109
109
  var PIXELDIFF_CONTOUR_MIN_AREA = 100;
@@ -216,7 +216,7 @@ async function ensureOpenCV() {
216
216
  async function preprocessFrame(framePath, scale) {
217
217
  const { data, info } = await (0, import_sharp.default)(framePath).resize({ width: scale, withoutEnlargement: true }).grayscale().blur(1).raw().toBuffer({ resolveWithObject: true });
218
218
  return {
219
- data: new Uint8Array(data.buffer),
219
+ data: new Uint8Array(data.buffer, data.byteOffset, data.byteLength),
220
220
  width: info.width,
221
221
  height: info.height
222
222
  };
@@ -297,16 +297,11 @@ var IoUTracker = class {
297
297
  }
298
298
  };
299
299
  async function computeAKAZEDiff(cvLib, frame1, frame2) {
300
- const mat1 = cvLib.matFromImageData({
301
- data: frame1.data,
302
- width: frame1.width,
303
- height: frame1.height
304
- });
305
- const mat2 = cvLib.matFromImageData({
306
- data: frame2.data,
307
- width: frame2.width,
308
- height: frame2.height
309
- });
300
+ const cv = cvLib;
301
+ const mat1 = new cv.Mat(frame1.height, frame1.width, cv.CV_8UC1);
302
+ mat1.data.set(frame1.data);
303
+ const mat2 = new cv.Mat(frame2.height, frame2.width, cv.CV_8UC1);
304
+ mat2.data.set(frame2.data);
310
305
  const kp1 = new cvLib.KeyPointVector();
311
306
  const kp2 = new cvLib.KeyPointVector();
312
307
  const desc1 = new cvLib.Mat();
@@ -704,6 +699,7 @@ async function finalizeOutput(ctx, selectedFrames) {
704
699
  outputFiles.push((0, import_node_path4.join)(outputPath, destName));
705
700
  }
706
701
  await ensureDir((0, import_node_path4.join)(outputPath, ".."));
702
+ await (0, import_promises3.rm)(outputPath, { recursive: true, force: true });
707
703
  await (0, import_promises3.rename)(stagingDir, outputPath);
708
704
  return outputFiles;
709
705
  }
package/dist/index.mjs CHANGED
@@ -63,7 +63,7 @@ var DBSCAN_MIN_PTS = 4;
63
63
  var IOU_THRESHOLD = 0.9;
64
64
  var DECAY_LAMBDA = 0.95;
65
65
  var ANIMATION_FRAME_THRESHOLD = 5;
66
- var MATCH_DISTANCE_THRESHOLD = 0.75;
66
+ var MATCH_DISTANCE_THRESHOLD = 0.25;
67
67
  var PIXELDIFF_GAUSSIAN_KERNEL = 3;
68
68
  var PIXELDIFF_BINARY_THRESHOLD = 30;
69
69
  var PIXELDIFF_CONTOUR_MIN_AREA = 100;
@@ -176,7 +176,7 @@ async function ensureOpenCV() {
176
176
  async function preprocessFrame(framePath, scale) {
177
177
  const { data, info } = await sharp(framePath).resize({ width: scale, withoutEnlargement: true }).grayscale().blur(1).raw().toBuffer({ resolveWithObject: true });
178
178
  return {
179
- data: new Uint8Array(data.buffer),
179
+ data: new Uint8Array(data.buffer, data.byteOffset, data.byteLength),
180
180
  width: info.width,
181
181
  height: info.height
182
182
  };
@@ -257,16 +257,11 @@ var IoUTracker = class {
257
257
  }
258
258
  };
259
259
  async function computeAKAZEDiff(cvLib, frame1, frame2) {
260
- const mat1 = cvLib.matFromImageData({
261
- data: frame1.data,
262
- width: frame1.width,
263
- height: frame1.height
264
- });
265
- const mat2 = cvLib.matFromImageData({
266
- data: frame2.data,
267
- width: frame2.width,
268
- height: frame2.height
269
- });
260
+ const cv = cvLib;
261
+ const mat1 = new cv.Mat(frame1.height, frame1.width, cv.CV_8UC1);
262
+ mat1.data.set(frame1.data);
263
+ const mat2 = new cv.Mat(frame2.height, frame2.width, cv.CV_8UC1);
264
+ mat2.data.set(frame2.data);
270
265
  const kp1 = new cvLib.KeyPointVector();
271
266
  const kp2 = new cvLib.KeyPointVector();
272
267
  const desc1 = new cvLib.Mat();
@@ -664,6 +659,7 @@ async function finalizeOutput(ctx, selectedFrames) {
664
659
  outputFiles.push(join3(outputPath, destName));
665
660
  }
666
661
  await ensureDir(join3(outputPath, ".."));
662
+ await rm(outputPath, { recursive: true, force: true });
667
663
  await rename(stagingDir, outputPath);
668
664
  return outputFiles;
669
665
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumy-pack/scene-sieve",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "CLI tool for extracting key frames from video and GIF files",
5
5
  "keywords": [
6
6
  "cli",