Commit 659c7529 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

+debug option

parent 1de804d9
......@@ -36,7 +36,7 @@ var Elphel = {
*/
putImageData: function(ctx,px,width,height){
var t0 = Date.now();
//var t0 = Date.now();
ctx.canvas.width = width;
ctx.canvas.height = height;
......@@ -44,7 +44,7 @@ var Elphel = {
var imgdata = new ImageData(new Uint8ClampedArray(px), width, height);
ctx.putImageData(imgdata,0,0);
console.log("drawImageData(): "+(Date.now()-t0)/1000+" s");
//console.log("drawImageData(): "+(Date.now()-t0)/1000+" s");
/*
// new: http://stackoverflow.com/questions/15908179/draw-image-from-pixel-array-on-canvas-with-putimagedata
......@@ -71,7 +71,7 @@ var Elphel = {
* version on destination canvas
*/
drawScaled: function(cnv_src,cnv_dst,width){
var t0 = Date.now();
//var t0 = Date.now();
var ctx = cnv_src[0].getContext('2d');
......@@ -97,7 +97,7 @@ var Elphel = {
// option 2
sctx.drawImage(cnv_src[0],0,0,ctx.canvas.width,ctx.canvas.height,0,0,sctx.canvas.width,sctx.canvas.height);
console.log("drawScaled(): "+(Date.now()-t0)/1000+" s");
//console.log("drawScaled(): "+(Date.now()-t0)/1000+" s");
}
},
......@@ -181,7 +181,7 @@ var Elphel = {
var nwd2 = true;
var t0 = Date.now();
//var t0 = Date.now();
// pixels is a long 1-D array with the following structure:
// pix[i+0] - red
......@@ -263,7 +263,7 @@ var Elphel = {
}
}
}
console.log("reorderJP4Blocks: "+(Date.now()-t0)/1000+" s");
//console.log("reorderJP4Blocks: "+(Date.now()-t0)/1000+" s");
return oPixels;
},
......@@ -286,7 +286,7 @@ var Elphel = {
*/
demosaicNearestNeighbor: function(pixels,width,height,mosaic=[["Gr","R"],["B" ,"Gb"]]){
var t0 = Date.now();
//var t0 = Date.now();
var oPixels = new Uint8Array(pixels.length/4);
......@@ -308,7 +308,7 @@ var Elphel = {
}
}
console.log("demosaicNearestNeighbor(): "+(Date.now()-t0)/1000+" s");
//console.log("demosaicNearestNeighbor(): "+(Date.now()-t0)/1000+" s");
return oPixels;
},
......@@ -334,7 +334,7 @@ var Elphel = {
*/
demosaicBilinear: function(pixels, width, height, mosaic=[["Gr","R"],["B" ,"Gb"]], precise=false){
var t0 = Date.now();
//var t0 = Date.now();
var oPixels = new Uint8Array(pixels.length);
......@@ -441,7 +441,7 @@ var Elphel = {
}
}
}
console.log("demosaicBilinear(): "+(Date.now()-t0)/1000+" s");
//console.log("demosaicBilinear(): "+(Date.now()-t0)/1000+" s");
return oPixels;
},
......@@ -541,7 +541,7 @@ var Elphel = {
*/
diffColorChannels: function(pixels,chn1,chn2,k=1){
var t0 = Date.now();
//var t0 = Date.now();
var i1 = 0;
if (chn1=="green") i1 = 1;
......@@ -559,7 +559,7 @@ var Elphel = {
pixels[4*i+3] = 255;
}
console.log("diffColorChannels(): "+(Date.now()-t0)/1000+" s");
//console.log("diffColorChannels(): "+(Date.now()-t0)/1000+" s");
return pixels;
},
......
......@@ -48,11 +48,14 @@
chn1: "red",
chn2: "green",
ndvi: false,
debug: false,
callback: function(){
console.log("callback");
}
},options);
var DEBUG = settings.debug;
// working time
var T0;
var TX;
......@@ -104,14 +107,18 @@
http.open("GET", rq, true);
TX = Date.now();
T0 = Date.now();
if (DEBUG){
TX = Date.now();
T0 = Date.now();
}
http.responseType = "blob";
http.onload = function(e) {
console.log("#"+elem.attr("id")+", file load time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
if (DEBUG){
console.log("#"+elem.attr("id")+", file load time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
}
if (this.status === 200) {
......@@ -171,15 +178,19 @@
$(this).draw({
fn: function(ctx){
console.log("#"+elem.attr("id")+", raw image drawn time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
if (DEBUG){
console.log("#"+elem.attr("id")+", raw image drawn time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
}
if (IMAGE_FORMAT=="JPEG"){
// if JP4/JP46 it will work through webworker and exit later on workers message
Elphel.Canvas.drawScaled(cnv_working,cnv_display,settings.width);
console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s");
if (DEBUG){
console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s");
}
$(this).trigger("canvas_ready");
......@@ -235,7 +246,9 @@
var worker = new Worker('js/webworker.js');
TX = Date.now();
if (DEBUG){
TX = Date.now();
}
//ctx.canvas.width = ctx.canvas.width/2;
//ctx.canvas.height = ctx.canvas.height/2;
......@@ -247,8 +260,10 @@
var image = ctx.getImageData(0,0,width,height);
var pixels = image.data;
console.log("#"+elem.attr("id")+", data from canvas for webworker time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
if (DEBUG){
console.log("#"+elem.attr("id")+", data from canvas for webworker time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
}
worker.postMessage({
mosaic: settings.mosaic,
......@@ -274,14 +289,18 @@
var width = e.data.width;
var height = e.data.height;
console.log("#"+elem.attr("id")+", worker time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
if (DEBUG){
console.log("#"+elem.attr("id")+", worker time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
}
Elphel.Canvas.putImageData(working_context,pixels,width,height);
Elphel.Canvas.drawScaled(cnv_working,cnv_display,settings.width);
// report time
console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s");
if (DEBUG){
// report time
console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s");
}
//trigger here
cnv_working.trigger("canvas_ready");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment