Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
659c7529
Commit
659c7529
authored
May 03, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+debug option
parent
1de804d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
26 deletions
+45
-26
elphel.js
src/jp4-canvas/elphel.js
+12
-12
jquery-jp4.js
src/jp4-canvas/jquery-jp4.js
+33
-14
No files found.
src/jp4-canvas/elphel.js
View file @
659c7529
...
...
@@ -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
;
},
...
...
src/jp4-canvas/jquery-jp4.js
View file @
659c7529
...
...
@@ -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"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment