Skip to content
Snippets Groups Projects
Commit a7dad2b8 authored by Jake Read's avatar Jake Read
Browse files

swap

parent be0670a1
No related branches found
No related tags found
No related merge requests found
/*
attempt of fft cross correlation for fast tracking / subpixel measurements
*/
import {
Hunkify,
Input,
Output,
State
} from '../hunks.js'
let correlate = (A, B) => {
// score a against b,
// a, b are str8 up matricies
}
export default function Correlate(){
Hunkify(this)
let imgIn = this.input('ImageData', 'frame')
let imgOut = this.output('ImageData', 'correlation')
let canvasA = $('<canvas>').get(0)
let ctxA = canvasA.getContext('2d')
ctxA.width = 100
ctxA.height = 100
this.dom = $('<div>').get(0)
this.init = () => {
}
this.onload = () => {
$(this.dom).append(canvasA)
}
this.loop = () => {
if(imgIn.io() && !imgOut.io()){
let img = imgIn.get()
// we want to set up a loop for this ... first we need some A: a slice of our img,
// since we're just checking against ourselves for now... let's take the middle
// to clip, I'll use this canvas context ...
// this is kind of surprising positioning inputs, but OK
ctxA.putImageData(img, -img.width / 2, -img.height / 2, img.width / 2, img.height / 2, ctxA.height, ctxA.width)
let a = ctxA.getImageData(0,0, ctxA.height, ctxA.width)
//console.log(a.width, a.height)
// and b is our original img,
// what's the move here?
for(let x = 0; x < img.width - a.width, x ++){
for(let y = 0; y < img.height - a.height, y ++){
}
}
}
}
}
/*
let img = imgIn.get()
let width = img.width
// to ah grayscale array,
let gs = []
let sum = 0
let avg = 0
for(let i = 0; i < img.data.length; i += 4){
sum = 0
sum += img.data[i]
sum += img.data[i + 1]
sum += img.data[i + 2]
avg = sum / 3
gs.push(avg) //, avg, avg, 255)
}
//let gray = new ImageData(Uint8ClampedArray.from(gs), img.width, img.height)
//imgOut.put(gray)
// conv. to grayscale,
// think we need this img ah grayscale array
// fft that ...
*/
/*
attempt of fft cross correlation for fast tracking / subpixel measurements
*/
import {
Hunkify,
Input,
Output,
State
} from '../hunks.js'
export default function FFTest(){
Hunkify(this)
}
......@@ -43,7 +43,6 @@ export default function RTCWebcam(){
setTimeout(capture, 2000)
*/
})
console.log(video.videoHeight, video.videoWidth)
}).catch((err) => {
console.log('get user stream error', err)
})
......
{
"interpreterName": "cuttlefish",
"interpreterVersion": "v0.1",
"hunks": [
{
"type": "manager",
"name": "nrol",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "1",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "view",
"name": "tlview",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "0",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "adhoc/webcam",
"name": "adhoc/webcam_2",
"outputs": [
{
"name": "frame",
"type": "ImageData",
"connections": [
{
"inHunkIndex": "3",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "adhoc/correlate",
"name": "adhoc/correlate_3",
"inputs": [
{
"name": "frame",
"type": "ImageData"
}
],
"outputs": [
{
"name": "correlation",
"type": "ImageData"
}
]
}
]
}
\ No newline at end of file
{
"interpreterName": "cuttlefish",
"interpreterVersion": "v0.1",
"hunks": [
{
"type": "manager",
"name": "nrol",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "1",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "view",
"name": "tlview",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "0",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "adhoc/webcam",
"name": "adhoc/webcam_2",
"outputs": [
{
"name": "frame",
"type": "ImageData",
"connections": [
{
"inHunkIndex": "4",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "image/displayimagedata",
"name": "image/displayimagedata_4",
"inputs": [
{
"name": "image",
"type": "ImageData"
}
]
},
{
"type": "adhoc/fftest",
"name": "adhoc/fftest_5",
"inputs": [
{
"name": "frame",
"type": "ImageData"
}
],
"outputs": [
{
"name": "fft",
"type": "ImageData",
"connections": [
{
"inHunkIndex": "3",
"inHunkInput": "0"
}
]
}
]
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment