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

+debug option

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