Last active
March 26, 2019 16:25
-
-
Save jt0dd/d1c0b13122d16e7774c2c8b2e7d173a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let chunkSize = 15; | |
| let inputWidth = 25; | |
| let image.dims = { | |
| w: 1920, | |
| h: 1080 | |
| } | |
| const myFunc = gpu.createKernel(function(imageTexture, imageWidth, x1, y1, x2, y2) { | |
| let x1 = this.thread.x * chunkSize; | |
| let y1 = this.thread.y * chunkSize; | |
| let x2 = x1 + inputWidth; | |
| let y2 = y1 + inputWidth; | |
| let input = []; | |
| for (let x = x1; x < x2; x++) { | |
| for (let y = y1; y < y2; y++) { | |
| let index = (y * imageWidth) + x; | |
| input.push(imageTexture[index]); | |
| } | |
| } | |
| return input; | |
| }).setOutput([inputWidth, inputWidth]); | |
| let matchLocations = []; | |
| for (let x1 = 0; x1 < image.dims.w - chunkSize; x1 += chunkSize){ | |
| for (let y1 = 0; y1 < image.dims.y - chunkSize; y1 += chunkSize){ | |
| let x2 = x1 + inputWidth; | |
| let y2 = y1 + inputWidth; | |
| if (subKernelThatRepresentsNetwork(myFunc(imageTexture, image.dims.w, x1, y1, x2, y2))[0] === 1){ | |
| matchLocations.push([x1, y1]); | |
| } | |
| } | |
| } |
Don't forget to use (renamed from outputToTexture in v2 of GPU.js) pipeline: true, in the options.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Move
return subKernelThatRepresentsNetwork(imageTexture, x1, y1, x2, y2); //outputs 0 or 1to outside of this function, and then simply dosubKernelThatRepresentsNetwork(myFunc(imageTexture, x1, y1, x2, y2));