Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Yves Didier
2021-12-16 18:41:51 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eedb2ec2cff1886d5c1f1aac600b73daa0218a42
eedb2ec2
1 parent
ae9b955c
debugging qrcodedetector
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
20 deletions
build/arcs.js
build/arcs.min.js
components/qrcodedetector.js
components/video.js
deps/jsqr/worker.js
tests/qrdetector/arcsapp.json
build/arcs.js
View file @
eedb2ec
/******/
"use strict"
;
/******/
var
__webpack_modules__
=
([
/* 0 */
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
...
...
@@ -1654,7 +1653,7 @@ Invocation.cast = function (obj, context) {
if
(
obj
.
storage
!==
undefined
)
{
let
data
=
null
;
if
(
typeof
(
localStorage
)
!==
"undefined"
)
{
let
item
=
localStorage
.
getItem
(
storage
.
key
);
let
item
=
localStorage
.
getItem
(
`ARCS.
${
storage
.
key
}
`
);
if
(
item
===
null
)
{
if
(
typeof
(
obj
.
storage
.
default
)
!==
"undefined"
)
{
data
=
obj
.
storage
.
default
;
...
...
build/arcs.min.js
View file @
eedb2ec
This diff is collapsed. Click to expand it.
components/qrcodedetector.js
View file @
eedb2ec
import
ARCS
from
'../build/arcs.js'
;
let
QRCodeDetector
;
QRCodeDetector
=
ARCS
.
Componenent
.
create
(
QRCodeDetector
=
ARCS
.
Component
.
create
(
function
()
{
let
busy
=
false
;
let
dataCache
=
null
;
const
worker
=
new
Worker
(
"../deps/jsqr/worker.js"
);
worker
.
addEventListener
(
"message"
,
({
data
}
=>
{
busy
=
false
;
dataCache
=
data
;
//let jsqrUrl = new URL('../deps/jsqr/jsQR.js');
const
code
=
`
//import jsQR from '../deps/jsQR.js';
//importScripts('sources/arcs.js/deps/jsqr/jsQR.js');
let jsQR = await import('../deps/jsQR.js');
self.addEventListener("message", e => {
const obj = e.data;
const qrData = jsQR(obj.data, obj.width, obj.height);
self.postMessage(qrData);
});
`
;
//const blob = new Blob([code], {type: 'application/javascript'});
//const worker = new Worker(URL.createObjectURL(blob),{type: "module"});
//
const
worker
=
new
Worker
(
'../../deps/jsqr/worker.js'
);
worker
.
addEventListener
(
"message"
,
((
data
)
=>
{
busy
=
false
;
dataCache
=
data
.
data
;
}));
this
.
detect
(
imageData
)
{
this
.
detect
=
function
(
imageData
)
{
if
(
!
busy
)
{
busy
=
true
;
worker
.
postMessage
(
imageData
);
...
...
components/video.js
View file @
eedb2ec
...
...
@@ -13,8 +13,12 @@ var LiveSource, VideoSource;
LiveSource
=
ARCS
.
Component
.
create
(
function
(
config
)
{
var
context
,
canvas
,
video
,
imageData
;
var
defaultWidth
=
config
||
config
.
width
||
320
;
var
defaultHeight
=
config
||
config
.
height
||
240
;
var
defaultWidth
=
320
;
var
defaultHeight
=
240
;
if
(
config
!==
undefined
)
{
if
(
config
.
width
!==
undefined
)
defaultWidth
=
config
.
width
;
if
(
config
.
height
!==
undefined
)
defaultHeight
=
config
.
height
;
}
var
self
=
this
;
var
handleMediaStream
=
function
(
stream
)
{
...
...
@@ -48,8 +52,18 @@ LiveSource = ARCS.Component.create(
this
.
setSize
=
function
(
x
,
y
)
{
};
this
.
start
=
function
()
{
if
(
!
video
||
!
canvas
)
{
createWidgets
();
}
setUserMedia
();
}
var
createWidgets
=
function
()
{
let
isVideoGiven
=
(
video
!=
null
);
let
isCanvasGiven
=
(
canvas
!=
null
);
video
=
video
||
document
.
createElement
(
"video"
);
canvas
=
canvas
||
document
.
createElement
(
"canvas"
);
canvas
.
width
=
video
.
width
=
defaultWidth
;
...
...
@@ -58,11 +72,15 @@ LiveSource = ARCS.Component.create(
canvas
.
style
.
height
=
canvas
.
height
+
"px"
;
// in order to hide our new elements
video
.
style
.
display
=
"none"
;
canvas
.
style
.
display
=
"none"
;
let
shadow
=
document
.
body
;
//.attachShadow({mode: 'open'});
shadow
.
appendChild
(
video
);
shadow
.
appendChild
(
canvas
);
if
(
!
isVideoGiven
)
{
video
.
style
.
display
=
"none"
;
shadow
.
appendChild
(
video
);
}
if
(
!
isCanvasGiven
)
{
canvas
.
style
.
display
=
"none"
;
shadow
.
appendChild
(
canvas
);
}
context
=
canvas
.
getContext
(
"2d"
);
};
...
...
@@ -70,7 +88,7 @@ LiveSource = ARCS.Component.create(
video
=
document
.
getElementById
(
videoId
);
canvas
=
document
.
getElementById
(
canvasId
);
if
(
video
===
undefined
||
canvas
===
undefined
)
{
if
(
video
===
null
||
canvas
===
null
)
{
console
.
log
(
"video elements not defined"
);
return
;
}
...
...
@@ -81,7 +99,7 @@ LiveSource = ARCS.Component.create(
setUserMedia
();
};
},
[
'grabFrame'
,
'setWidgets'
],
[
'
start'
,
'
grabFrame'
,
'setWidgets'
],
[
'onReady'
,
'onImage'
]
);
...
...
deps/jsqr/worker.js
View file @
eedb2ec
import
jsQR
from
'./jsQR.js'
;
import
Scripts
(
'./jsQR.js'
)
;
self
.
addEventListener
(
"message"
,
e
=>
{
const
obj
=
e
.
data
;
...
...
tests/qrdetector/arcsapp.json
View file @
eedb2ec
...
...
@@ -22,12 +22,14 @@
"sheets"
:
{
"init"
:
{
"preconnections"
:
[
{
"destination"
:
"video"
,
"slot"
:
"setWidgets"
,
"value"
:
[
"video"
]
}
,
{
"destination"
:
"video"
,
"slot"
:
"setWidgets"
,
"value"
:
[
"video"
]
}
],
"connections"
:
[
{
"source"
:
"video"
,
"signal"
:
"onReady"
,
"destination"
:
"statemachine"
,
"slot"
:
"next"
}
],
"postconnections"
:
[],
"postconnections"
:
[
{
"destination"
:
"video"
,
"slot"
:
"start"
,
"value"
:
[]
}
],
"cleanups"
:
[]
},
"start"
:
{
...
...
Please
register
or
login
to post a comment