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
didier
2016-05-18 14:00:50 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8646b4f0f5c629b6f56f46bbd534e581985f5d32
8646b4f0
1 parent
548688a6
improvements on video, second way of detecting dices
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
components/dicedetector2.js
components/video.js
components/dicedetector2.js
View file @
8646b4f
arcs_module
(
function
(
ARCS
,
tracking
,
POS
,
SVD
)
{
function
(
ARCS
,
_
tracking
,
POS
,
SVD
)
{
var
DiceDetector
,
DiceFace
,
recoverImageData
;
var
debugFeatures
=
function
(
context
,
corners
)
{
for
(
var
i
=
0
;
i
<
corners
.
length
/
2
;
i
++
)
{
var
color
=
'#'
+
Math
.
floor
(
Math
.
random
()
*
16777215
).
toString
(
16
);
context
.
fillStyle
=
color
;
context
.
strokeStyle
=
color
;
context
.
fillRect
(
corners
[
2
*
i
],
corners
[
2
*
i
+
1
],
4
,
4
);
}
};
/**
* Dice face description
* @typedef {Object} DiceFaceDescription
...
...
@@ -152,7 +164,7 @@ arcs_module(
//<--
var
context
=
temporaryCanvas
.
getContext
(
"2d"
);
context
.
putImageData
(
this
.
imageData
,
0
,
0
);
SURF
.
drawIPoints
(
context
,
this
.
keyPoint
s
);
debugFeatures
(
context
,
this
.
corner
s
);
//-->
};
...
...
@@ -183,19 +195,18 @@ arcs_module(
this
.
imageData
=
{};
//<--
this
.
imageData
=
recoverImageData
(
descr
.
imageId
);
var
grayImage
=
tracking
.
Image
.
grayscale
(
tracking
.
Image
.
blur
(
this
.
imageData
.
data
,
this
.
imageData
.
width
,
this
.
imageData
.
height
),
this
.
imageData
.
height
,
blurRadius
),
this
.
imageData
.
width
,
this
.
imageData
.
height
);
this
.
corners
=
tracking
.
Fast
.
findCorners
(
grayImage
,
this
.
imageData
.
width
,
this
.
imageData
.
height
);
this
.
descriptors
=
tracking
.
Brief
.
getDescriptors
(
grayImage
,
this
.
imageData
.
width
,
corners1
);
/*var grayImage = SURF.grayImage(this.imageData);
this.keyPoints = SURF.surfDetDes(grayImage/*, 3,4,2,0.001*/
);
*
/
this
.
descriptors
=
tracking
.
Brief
.
getDescriptors
(
grayImage
,
this
.
imageData
.
width
,
this
.
corners
);
this
.
debugImage
();
//-->
...
...
@@ -250,7 +261,7 @@ arcs_module(
* @slot
*/
this
.
detect
=
function
(
image
)
{
var
keyPoints
=
[];
//
var keyPoints = [];
var
globalMatches
=
[];
var
points2D
=
[];
...
...
@@ -266,27 +277,25 @@ arcs_module(
// will give hints about using surfDetDes(...)
//<--
/*grayImage = SURF.grayImage(image);
keyPoints = SURF.surfDetDes(grayImage/*, 3,4,2,0.001*/
);
*
/
grayImage
=
tracking
.
Image
.
grayscale
(
tracking
.
Image
.
blur
(
image
.
data
,
image
.
width
,
image
.
height
,
blurRadius
),
image
.
width
,
image
.
height
);
var
corners
=
tracking
.
Fast
.
findCorners
(
grayImage
,
image
.
width
,
image
.
height
)
)
;
var
corners
=
tracking
.
Fast
.
findCorners
(
grayImage
,
image
.
width
,
image
.
height
);
var
descriptors
=
tracking
.
Brief
.
getDescriptors
(
grayImage
,
image
.
width
,
corners
);
//-->
for
(
i
=
0
;
i
<
6
;
i
++
)
{
if
(
keyPoint
s
.
length
>
0
)
{
if
(
corner
s
.
length
>
0
)
{
// TODO #3: find matches between acquired image (img) and die faces.
// See documentation of global object SURF.
// It will give hints about using getMatches(...)
//<--
var
matches
=
tracking
.
Brief
.
reciprocalMatch
(
corners
,
descriptors
,
diceFaces
[
i
].
corners
,
diceFaces
[
i
].
descriptors
);
//console.log("matches length ", matches.length);
//-->
// if there are enough matches ...
if
(
matches
.
length
>=
6
)
{
console
.
log
(
"Found matches with image "
,
diceFaces
[
i
].
imageId
);
//
console.log("Found matches with image ", diceFaces[i].imageId);
for
(
j
=
0
;
j
<
matches
.
length
;
j
++
)
{
// TODO #5
// insert, at the back of the point2D array,
...
...
@@ -296,11 +305,8 @@ arcs_module(
// See also documentation of object of type Array in javascript
//<--
points2D
.
push
(
matches
[
j
].
keypoint1
);
points3D
.
push
(
diceFaces
[
i
].
get3DCounterpart
(
matches
[
j
].
keypoint1
));
/*points2D.push(matches[j][0]);
points3D.push(
diceFaces[i].get3DCounterpart(matches[j][1].x, matches[j][1].y));*/
points2D
.
push
({
x
:
matches
[
j
].
keypoint1
[
0
],
y
:
matches
[
j
].
keypoint1
[
1
]}
);
points3D
.
push
(
diceFaces
[
i
].
get3DCounterpart
(
matches
[
j
].
keypoint2
[
0
],
matches
[
j
].
keypoint2
[
1
]
));
//-->
}
...
...
@@ -317,7 +323,7 @@ arcs_module(
//<--
if
(
debugCanvas
)
{
SURF
.
drawIPoints
(
debugCanvas
.
getContext
(
"2d"
),
points2D
);
debugFeatures
(
debugCanvas
.
getContext
(
"2d"
),
corners
);
}
//-->
...
...
@@ -333,6 +339,7 @@ arcs_module(
//<--
pose
=
poseEstimator
.
pose
(
points2D
,
points3D
);
//pose = {};
pose
.
rotation
=
pose
.
bestRotation
;
pose
.
translation
=
pose
.
bestTranslation
;
marker
.
id
=
currentId
;
...
...
@@ -370,7 +377,6 @@ arcs_module(
},
[
"deps/tracking.js/tracking"
,
//{name:"deps/surf/surf", exports:"SURF"},
{
name
:
"deps/pose/posit_gen"
,
exports
:
"POS"
},
{
name
:
"deps/pose/svd"
,
exports
:
"SVD"
}
]
...
...
components/video.js
View file @
8646b4f
...
...
@@ -15,6 +15,8 @@ arcs_module(function(ARCS) {
}
else
{
video
.
src
=
stream
;
}
video
.
videoWidth
=
defaultWidth
;
video
.
videoHeight
=
defaultHeight
;
self
.
emit
(
"onReady"
);
};
...
...
@@ -40,7 +42,6 @@ arcs_module(function(ARCS) {
this
.
grabFrame
=
function
()
{
if
(
context
===
undefined
||
canvas
===
undefined
||
video
===
undefined
)
return
;
if
(
video
.
readyState
===
video
.
HAVE_ENOUGH_DATA
)
{
context
.
drawImage
(
video
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
imageData
=
context
.
getImageData
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
...
...
Please
register
or
login
to post a comment