Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 1 addition & 43 deletions src/jsfeatNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,49 +507,7 @@ class homography2d extends motion_model {

jsfeatNext.cache = cache;

jsfeatNext.pyramid_t = class pyramid_t extends jsfeatNext {
public levels: number;
public data: any;
private pyrdown: any;

constructor(levels: number) {
super();
this.levels = levels | 0;
this.data = new Array(levels);
const _imgproc = new jsfeatNext.imgproc();
this.pyrdown = _imgproc.pyrdown;
}

allocate(start_w: number, start_h: number, data_type: number): void {
let i = this.levels;
while (--i >= 0) {
this.data[i] = new matrix_t(start_w >> i, start_h >> i, data_type);
}
}

build(input: matrix_t, skip_first_level: boolean): void {
if (typeof skip_first_level === "undefined") {
skip_first_level = true;
}
// just copy data to first level
let i = 2,
a = input,
b: any = this.data[0];
if (!skip_first_level) {
let j = input.cols * input.rows;
while (--j >= 0) {
b.data[j] = input.data[j];
}
}
b = this.data[1];
this.pyrdown(a, b);
for (; i < this.levels; ++i) {
a = b;
b = this.data[i];
this.pyrdown(a, b);
}
}
};
jsfeatNext.pyramid_t = pyramid_t;

jsfeatNext.transform = transform;

Expand Down
58 changes: 52 additions & 6 deletions src/pyramid_t/pyramid_t.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,54 @@
import jsfeatNext from "../core/core";
import { matrix_t } from "../matrix_t/matrix_t";
export class pyramid_t {
data: any;
levels: number;
constructor(levels: number) {}
allocate(start_w: number, start_h: number, data_type: number): void {}
build(input: matrix_t, skip_first_level: boolean): void {}
import { imgproc } from "../imgproc/imgproc";

/**
* Real implementation, moved out of the src/jsfeatNext.ts monolith (issue #47).
* This file previously held a type-only stub — the implementation below is the
* inline code from the monolith, verbatim (the only change: the constructor
* instantiates the imgproc module directly instead of via the
* jsfeatNext.imgproc static slot).
*/
export class pyramid_t extends jsfeatNext {
public levels: number;
public data: any;
private pyrdown: any;

constructor(levels: number) {
super();
this.levels = levels | 0;
this.data = new Array(levels);
const _imgproc = new imgproc();
this.pyrdown = _imgproc.pyrdown;
}

allocate(start_w: number, start_h: number, data_type: number): void {
let i = this.levels;
while (--i >= 0) {
this.data[i] = new matrix_t(start_w >> i, start_h >> i, data_type);
}
}

build(input: matrix_t, skip_first_level: boolean): void {
if (typeof skip_first_level === "undefined") {
skip_first_level = true;
}
// just copy data to first level
let i = 2,
a = input,
b: any = this.data[0];
if (!skip_first_level) {
let j = input.cols * input.rows;
while (--j >= 0) {
b.data[j] = input.data[j];
}
}
b = this.data[1];
this.pyrdown(a, b);
for (; i < this.levels; ++i) {
a = b;
b = this.data[i];
this.pyrdown(a, b);
}
}
}