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
e233bb6d
Commit
e233bb6d
authored
Apr 04, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reordering jp4 blocks in web worker
parent
4bdc75f5
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
455 additions
and
380 deletions
+455
-380
Makefile
src/jp4-canvas/Makefile
+2
-1
elphel.js
src/jp4-canvas/elphel.js
+321
-327
jquery-jp4.js
src/jp4-canvas/jquery-jp4.js
+99
-52
webworker.js
src/jp4-canvas/webworker.js
+33
-0
No files found.
src/jp4-canvas/Makefile
View file @
e233bb6d
...
@@ -8,7 +8,8 @@ DOCS= jp4-canvas.html \
...
@@ -8,7 +8,8 @@ DOCS= jp4-canvas.html \
LIBS
=
elphel.js
\
LIBS
=
elphel.js
\
exif.js
\
exif.js
\
jquery-jp4.js
\
jquery-jp4.js
\
jcanvas.js
jcanvas.js
\
webworker.js
PHP_SCRIPTS
=
get-image.php
PHP_SCRIPTS
=
get-image.php
...
...
src/jp4-canvas/elphel.js
View file @
e233bb6d
This diff is collapsed.
Click to expand it.
src/jp4-canvas/jquery-jp4.js
View file @
e233bb6d
...
@@ -59,12 +59,14 @@
...
@@ -59,12 +59,14 @@
var
PIXELS
=
[];
var
PIXELS
=
[];
var
cnv_working
=
$
(
"<canvas>"
,{
id
:
"result"
}).
css
({
var
cnv_working
=
$
(
"<canvas>"
,{
id
:
"working"
});
display
:
"none"
var
cnv_display
=
$
(
"<canvas>"
,{
id
:
"display"
});
});
var
cnv_display
=
$
(
"<canvas>"
,{
id
:
"scaled"
});
// hide working canvas
cnv_working
.
css
({
display
:
"none"
});
elem
.
append
(
cnv_working
).
append
(
cnv_display
);
elem
.
append
(
cnv_working
);
elem
.
append
(
cnv_display
);
get_image
();
get_image
();
//end
//end
...
@@ -72,14 +74,13 @@
...
@@ -72,14 +74,13 @@
function
get_image
(){
function
get_image
(){
var
canvas
=
cnv_working
;
var
canvas
=
cnv_working
;
var
scaled_canvas
=
cnv_display
;
//reset format
//reset format
IMAGE_FORMAT
=
"JPEG"
;
IMAGE_FORMAT
=
"JPEG"
;
var
http
=
new
XMLHttpRequest
();
var
http
=
new
XMLHttpRequest
();
var
rq
=
""
;
var
rq
=
""
;
if
(
settings
.
port
!=
""
){
if
(
settings
.
port
!=
""
){
rq
=
"get-image.php?port="
+
settings
.
port
+
"&rel=bimg&ts="
+
Date
.
now
();
rq
=
"get-image.php?port="
+
settings
.
port
+
"&rel=bimg&ts="
+
Date
.
now
();
settings
.
refresh
=
true
;
settings
.
refresh
=
true
;
...
@@ -105,7 +106,6 @@
...
@@ -105,7 +106,6 @@
x
:
0
,
y
:
0
,
x
:
0
,
y
:
0
,
source
:
heavyImage
,
source
:
heavyImage
,
load
:
redraw
,
load
:
redraw
,
//scale: 1,
fromCenter
:
false
fromCenter
:
false
});
});
});
});
...
@@ -113,17 +113,21 @@
...
@@ -113,17 +113,21 @@
heavyImage
.
src
=
URL
.
createObjectURL
(
http
.
response
);
heavyImage
.
src
=
URL
.
createObjectURL
(
http
.
response
);
}
}
};
};
http
.
send
();
http
.
send
();
}
}
function
redraw
(){
function
redraw
(){
$
(
this
).
draw
({
$
(
this
).
draw
({
fn
:
function
(
ctx
){
fn
:
function
(
ctx
){
var
t0
=
Date
.
now
();
var
t0
=
Date
.
now
();
if
((
IMAGE_FORMAT
==
"JP4"
)
||
(
IMAGE_FORMAT
==
"JP46"
)){
if
((
IMAGE_FORMAT
==
"JP4"
)
||
(
IMAGE_FORMAT
==
"JP46"
)){
if
(
settings
.
fast
){
if
(
settings
.
fast
){
quickestPreview
(
ctx
);
quickestPreview
(
ctx
);
}
else
{
}
/*
else{
Elphel.reorderJP4Blocks(ctx,"JP4");
Elphel.reorderJP4Blocks(ctx,"JP4");
if (settings.precise){
if (settings.precise){
...
@@ -153,12 +157,15 @@
...
@@ -153,12 +157,15 @@
}
}
}
}
*/
// RGB -> YCbCr x SATURATION -> RGB
// RGB -> YCbCr x SATURATION -> RGB
// Taking SATURATION[0] = 1/GAMMA[0] (green pixel of GR-line)
// Taking SATURATION[0] = 1/GAMMA[0] (green pixel of GR-line)
//saturation(ctx,SATURATION[0]);
//saturation(ctx,SATURATION[0]);
}
}
Elphel
.
drawScaled
(
cnv_working
,
cnv_display
,
settings
.
width
);
console
.
log
(
"#"
+
elem
.
attr
(
"id"
)
+
", time: "
+
(
Date
.
now
()
-
t0
)
/
1000
+
" s"
);
console
.
log
(
"#"
+
elem
.
attr
(
"id"
)
+
", time: "
+
(
Date
.
now
()
-
t0
)
/
1000
+
" s"
);
// custom event
$
(
this
).
trigger
(
"canvas_ready"
);
$
(
this
).
trigger
(
"canvas_ready"
);
if
(
settings
.
refresh
)
get_image
();
if
(
settings
.
refresh
)
get_image
();
...
@@ -167,10 +174,50 @@
...
@@ -167,10 +174,50 @@
}
}
function
quickestPreview
(
ctx
){
function
quickestPreview
(
ctx
){
Elphel
.
reorderJP4Blocks
(
ctx
,
"JP4"
,
settings
.
mosaic
,
settings
.
fast
);
Elphel
.
applySaturation
(
ctx
,
SATURATION
[
0
]);
var
worker
=
new
Worker
(
'js/webworker.js'
);
var
width
=
ctx
.
canvas
.
width
;
var
height
=
ctx
.
canvas
.
height
;
var
image
=
ctx
.
getImageData
(
0
,
0
,
width
,
height
);
var
pixels
=
image
.
data
;
worker
.
postMessage
({
mosaic
:
settings
.
mosaic
,
format
:
IMAGE_FORMAT
,
width
:
ctx
.
canvas
.
width
,
height
:
ctx
.
canvas
.
height
,
pixels
:
pixels
.
buffer
,
settings
:
{
fast
:
settings
.
fast
,
channel
:
settings
.
channel
,
diff
:
settings
.
diff
,
ndvi
:
settings
.
ndvi
},
},[
pixels
.
buffer
]);
worker
.
onmessage
=
function
(
e
){
var
pixels
=
new
Uint8Array
(
e
.
data
.
pixels
);
var
working_context
=
cnv_working
[
0
].
getContext
(
'2d'
);
var
width
=
e
.
data
.
width
;
var
height
=
e
.
data
.
height
;
Elphel
.
Canvas
.
putImageData
(
working_context
,
pixels
,
width
,
height
);
Elphel
.
Canvas
.
drawScaled
(
cnv_working
,
cnv_display
,
settings
.
width
);
}
}
}
/**
* plugin globals get changed
* @FLIPV - not used
* @FLIPH - not used
* @BAYER - not used
* @IMAGE_FORMAT - used
* @SATURATION[i] - not used
*/
function
parseEXIFMakerNote
(
src
){
function
parseEXIFMakerNote
(
src
){
var
exif_orientation
=
EXIF
.
getTag
(
src
,
"Orientation"
);
var
exif_orientation
=
EXIF
.
getTag
(
src
,
"Orientation"
);
...
@@ -239,7 +286,7 @@
...
@@ -239,7 +286,7 @@
*/
*/
for
(
i
=
0
;
i
<
4
;
i
++
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
//SATURATION[i] = 1/gammas[i];
//SATURATION[i] = 1/gammas[i];
//SATURATION[i] = 1.75; //
nightmate
time
//SATURATION[i] = 1.75; //
nightmarish
time
SATURATION
[
i
]
=
2
;
SATURATION
[
i
]
=
2
;
}
}
//console.log("MakerNote: Saturations: "+SATURATION[0]+" "+SATURATION[1]+" "+SATURATION[2]+" "+SATURATION[3]);
//console.log("MakerNote: Saturations: "+SATURATION[0]+" "+SATURATION[1]+" "+SATURATION[2]+" "+SATURATION[3]);
...
...
src/jp4-canvas/webworker.js
0 → 100644
View file @
e233bb6d
importScripts
(
'elphel.js'
);
self
.
onmessage
=
function
(
e
)
{
var
W
=
e
.
data
.
width
;
var
H
=
e
.
data
.
height
;
var
Mosaic
=
e
.
data
.
mosaic
;
var
Format
=
e
.
data
.
format
;
var
settings
=
e
.
data
.
settings
;
var
Pixels
=
new
Uint8Array
(
e
.
data
.
pixels
);
var
reorderedPixels
=
Elphel
.
Pixels
.
reorderBlocksJPx
(
Pixels
,
W
,
H
,
Format
,
Mosaic
,
settings
.
fast
);
//reorder first then downscale
if
(
settings
.
fast
){
W
=
W
/
2
;
H
=
H
/
2
;
}
Elphel
.
Pixels
.
applySaturation
(
reorderedPixels
,
W
,
H
,
2
);
postMessage
({
width
:
W
,
height
:
H
,
pixels
:
reorderedPixels
.
buffer
},[
reorderedPixels
.
buffer
]);
//Elphel.test();
};
\ No newline at end of file
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