Loading src/jp4-canvas/elphel.js +12 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading @@ -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'); Loading @@ -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"); } }, Loading Loading @@ -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 Loading Loading @@ -263,7 +263,7 @@ var Elphel = { } } } console.log("reorderJP4Blocks: "+(Date.now()-t0)/1000+" s"); //console.log("reorderJP4Blocks: "+(Date.now()-t0)/1000+" s"); return oPixels; }, Loading @@ -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); Loading @@ -308,7 +308,7 @@ var Elphel = { } } console.log("demosaicNearestNeighbor(): "+(Date.now()-t0)/1000+" s"); //console.log("demosaicNearestNeighbor(): "+(Date.now()-t0)/1000+" s"); return oPixels; }, Loading @@ -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); Loading Loading @@ -441,7 +441,7 @@ var Elphel = { } } } console.log("demosaicBilinear(): "+(Date.now()-t0)/1000+" s"); //console.log("demosaicBilinear(): "+(Date.now()-t0)/1000+" s"); return oPixels; }, Loading Loading @@ -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; Loading @@ -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; }, Loading src/jp4-canvas/jquery-jp4.js +33 −14 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -104,14 +107,18 @@ http.open("GET", rq, true); if (DEBUG){ TX = Date.now(); T0 = Date.now(); } http.responseType = "blob"; http.onload = function(e) { if (DEBUG){ console.log("#"+elem.attr("id")+", file load time: "+(Date.now()-TX)/1000+" s"); TX = Date.now(); } if (this.status === 200) { Loading Loading @@ -171,15 +178,19 @@ $(this).draw({ fn: function(ctx){ 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); if (DEBUG){ console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s"); } $(this).trigger("canvas_ready"); Loading Loading @@ -235,7 +246,9 @@ var worker = new Worker('js/webworker.js'); if (DEBUG){ TX = Date.now(); } //ctx.canvas.width = ctx.canvas.width/2; //ctx.canvas.height = ctx.canvas.height/2; Loading @@ -247,8 +260,10 @@ var image = ctx.getImageData(0,0,width,height); var pixels = image.data; 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, Loading @@ -274,14 +289,18 @@ var width = e.data.width; var height = e.data.height; 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); if (DEBUG){ // report time console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s"); } //trigger here cnv_working.trigger("canvas_ready"); } Loading Loading
src/jp4-canvas/elphel.js +12 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading @@ -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'); Loading @@ -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"); } }, Loading Loading @@ -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 Loading Loading @@ -263,7 +263,7 @@ var Elphel = { } } } console.log("reorderJP4Blocks: "+(Date.now()-t0)/1000+" s"); //console.log("reorderJP4Blocks: "+(Date.now()-t0)/1000+" s"); return oPixels; }, Loading @@ -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); Loading @@ -308,7 +308,7 @@ var Elphel = { } } console.log("demosaicNearestNeighbor(): "+(Date.now()-t0)/1000+" s"); //console.log("demosaicNearestNeighbor(): "+(Date.now()-t0)/1000+" s"); return oPixels; }, Loading @@ -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); Loading Loading @@ -441,7 +441,7 @@ var Elphel = { } } } console.log("demosaicBilinear(): "+(Date.now()-t0)/1000+" s"); //console.log("demosaicBilinear(): "+(Date.now()-t0)/1000+" s"); return oPixels; }, Loading Loading @@ -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; Loading @@ -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; }, Loading
src/jp4-canvas/jquery-jp4.js +33 −14 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -104,14 +107,18 @@ http.open("GET", rq, true); if (DEBUG){ TX = Date.now(); T0 = Date.now(); } http.responseType = "blob"; http.onload = function(e) { if (DEBUG){ console.log("#"+elem.attr("id")+", file load time: "+(Date.now()-TX)/1000+" s"); TX = Date.now(); } if (this.status === 200) { Loading Loading @@ -171,15 +178,19 @@ $(this).draw({ fn: function(ctx){ 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); if (DEBUG){ console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s"); } $(this).trigger("canvas_ready"); Loading Loading @@ -235,7 +246,9 @@ var worker = new Worker('js/webworker.js'); if (DEBUG){ TX = Date.now(); } //ctx.canvas.width = ctx.canvas.width/2; //ctx.canvas.height = ctx.canvas.height/2; Loading @@ -247,8 +260,10 @@ var image = ctx.getImageData(0,0,width,height); var pixels = image.data; 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, Loading @@ -274,14 +289,18 @@ var width = e.data.width; var height = e.data.height; 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); if (DEBUG){ // report time console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s"); } //trigger here cnv_working.trigger("canvas_ready"); } Loading