end
def acquisition
- stream = ChunkyPNG::Datastream.from_file('./vem/sample.png')
- array = ChunkyPNG::Chunk::ImageData.combine_chunks(stream.data_chunks).unpack('C*')
- "#{array}"
- # 画像ファイルをひらく
++ # 画像ファイルをひらく
+ File.open("img", "r") do |file|
+ $img_array = JSON.load(file)
+ end
+
+ # 画像配列の長さ取得
+ img_length = $img_array.length
+
+ # リサイズ用の配列生成
+ array128 = Array.new(128).map{ Array.new(128) }
+
+ # 元画像をリサイズ
+ for x in 0..127 do
+ for y in 0..127 do
+ array128[y][x] = $img_array[y*16][x*16]
+ end
+ end
+
+ "#{array128}"
end
def getCondition
function startAcq(){
- console.log("start");
-- $("button").text("stop");
++ $("button").text("stop");
ws = new WebSocket("ws://localhost:3000");
// メッセージ受信時の処理
}else{
ws.send("acq");
draw(JSON.parse(event.data));
- console.log(event.data);
-- console.log(i);
++ console.log(i);
i = i + 1;
}
};
}
function stopAcq(){
- $("button").text("start");
++ $("button").text("start");
console.log("stop");
- $("button").text("start");
ws.close(1000, "close");
}
// CanvasのコンテキストにImageDataを設定
ctx.putImageData(imgData, 0, 0);
}
-
+