mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Add video sensing debug C_CELL and AB_CELL views
- Rename UV to UV_CELL, UV cannot be rendered in a non-cell format Modify C and AB views as well to better represent in color the work being done. If you watch the debug views with XY_CELL, AB_CELL, C_CELL, and UV_CELL you can see how AB_CELL and C_CELL affect UV_CELL in similar color patterns.
This commit is contained in:
parent
0a58a6d806
commit
b012d60689
1 changed files with 75 additions and 13 deletions
|
@ -6,15 +6,17 @@ const THRESHOLD = 10;
|
||||||
|
|
||||||
const OUTPUT = {
|
const OUTPUT = {
|
||||||
INPUT: -1,
|
INPUT: -1,
|
||||||
XYT: 0,
|
XY: 0,
|
||||||
XYT_CELL: 1,
|
XY_CELL: 1,
|
||||||
XY: 2,
|
AB: 2,
|
||||||
XY_CELL: 3,
|
AB_CELL: 3,
|
||||||
T: 4,
|
T: 4,
|
||||||
T_CELL: 5,
|
T_CELL: 5,
|
||||||
C: 6,
|
XYT: 6,
|
||||||
AB: 7,
|
XYT_CELL: 7,
|
||||||
UV: 8
|
C: 8,
|
||||||
|
C_CELL: 9,
|
||||||
|
UV_CELL: 10
|
||||||
};
|
};
|
||||||
|
|
||||||
class VideoMotionView {
|
class VideoMotionView {
|
||||||
|
@ -186,19 +188,79 @@ class VideoMotionView {
|
||||||
const {gradX, gradY, gradT} = this._grads(address);
|
const {gradX, gradY, gradT} = this._grads(address);
|
||||||
buffer[address] =
|
buffer[address] =
|
||||||
(0xff << 24) +
|
(0xff << 24) +
|
||||||
((gradY * gradT) << 8) +
|
(((Math.sqrt(gradY * gradT) * 0x0f) & 0xff) << 8) +
|
||||||
(gradX * gradT);
|
((Math.sqrt(gradX * gradT) * 0x0f) & 0xff);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (this.output === OUTPUT.C_CELL) {
|
||||||
|
const winStep = (WINSIZE * 2) + 1;
|
||||||
|
const wmax = WIDTH - WINSIZE - 1;
|
||||||
|
const hmax = HEIGHT - WINSIZE - 1;
|
||||||
|
|
||||||
|
this._eachCell(WINSIZE + 1, WINSIZE + 1, wmax, hmax, winStep, winStep, eachAddress => {
|
||||||
|
let C2 = 0;
|
||||||
|
let C1 = 0;
|
||||||
|
let n = 0;
|
||||||
|
|
||||||
|
eachAddress(address => {
|
||||||
|
const {gradX, gradY, gradT} = this._grads(address);
|
||||||
|
C2 += gradX * gradT;
|
||||||
|
C1 += gradY * gradT;
|
||||||
|
n += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
C2 = Math.sqrt(C2);
|
||||||
|
C1 = Math.sqrt(C1);
|
||||||
|
|
||||||
|
eachAddress(address => {
|
||||||
|
buffer[address] =
|
||||||
|
(0xff << 24) +
|
||||||
|
((C1 & 0xff) << 8) +
|
||||||
|
((C2 & 0xff) << 0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else if (this.output === OUTPUT.AB) {
|
} else if (this.output === OUTPUT.AB) {
|
||||||
this._eachAddress(1, 1, WIDTH - 1, HEIGHT - 1, address => {
|
this._eachAddress(1, 1, WIDTH - 1, HEIGHT - 1, address => {
|
||||||
const {gradX, gradY} = this._grads(address);
|
const {gradX, gradY} = this._grads(address);
|
||||||
buffer[address] =
|
buffer[address] =
|
||||||
(0xff << 24) +
|
(0xff << 24) +
|
||||||
((gradX * gradY) << 16) +
|
(((gradX * gradY) & 0xff) << 16) +
|
||||||
((gradY * gradY) << 8) +
|
(((gradY * gradY) & 0xff) << 8) +
|
||||||
(gradX * gradX);
|
((gradX * gradX) & 0xff);
|
||||||
});
|
});
|
||||||
} else if (this.output === OUTPUT.UV) {
|
}
|
||||||
|
if (this.output === OUTPUT.AB_CELL) {
|
||||||
|
const winStep = (WINSIZE * 2) + 1;
|
||||||
|
const wmax = WIDTH - WINSIZE - 1;
|
||||||
|
const hmax = HEIGHT - WINSIZE - 1;
|
||||||
|
|
||||||
|
this._eachCell(WINSIZE + 1, WINSIZE + 1, wmax, hmax, winStep, winStep, eachAddress => {
|
||||||
|
let A2 = 0;
|
||||||
|
let A1B2 = 0;
|
||||||
|
let B1 = 0;
|
||||||
|
let n = 0;
|
||||||
|
|
||||||
|
eachAddress(address => {
|
||||||
|
const {gradX, gradY} = this._grads(address);
|
||||||
|
A2 += gradX * gradX;
|
||||||
|
A1B2 += gradX * gradY;
|
||||||
|
B1 += gradY * gradY;
|
||||||
|
n += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
A2 = Math.sqrt(A2);
|
||||||
|
A1B2 = Math.sqrt(A1B2);
|
||||||
|
B1 = Math.sqrt(B1);
|
||||||
|
|
||||||
|
eachAddress(address => {
|
||||||
|
buffer[address] =
|
||||||
|
(0xff << 24) +
|
||||||
|
((A1B2 & 0xff) << 16) +
|
||||||
|
((B1 & 0xff) << 8) +
|
||||||
|
(A2 & 0xff);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (this.output === OUTPUT.UV_CELL) {
|
||||||
const winStep = (WINSIZE * 2) + 1;
|
const winStep = (WINSIZE * 2) + 1;
|
||||||
const wmax = WIDTH - WINSIZE - 1;
|
const wmax = WIDTH - WINSIZE - 1;
|
||||||
const hmax = HEIGHT - WINSIZE - 1;
|
const hmax = HEIGHT - WINSIZE - 1;
|
||||||
|
|
Loading…
Reference in a new issue