Skip to content

Commit ca12d5a

Browse files
committed
border labeling param changes after dev cleanup
1 parent 5ec3108 commit ca12d5a

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

aframe/examples/assets/white_000.png

735 Bytes
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script
2+
src="https://cdn.jsdelivr.net/gh/aframevr/aframe@1c2407b26c61958baa93967b5412487cd94b290b/dist/aframe-master.min.js"></script>
3+
<script src="../build/aframe-ar.js"></script>
4+
5+
<body style='margin : 0px; overflow: hidden;'>
6+
<div style='position: fixed; top: 10px; text-align: center; z-index: 1; width: 100%; background: gray;'>
7+
White region marker (markers with white borders) example, use <a href="assets/white_000.png">this inverted marker.</a>
8+
</div>
9+
<a-scene embedded
10+
arjs='sourceType: webcam; detectionMode: mono_and_matrix; matrixCodeType: 3x3; labelingMode: white_region;'>
11+
12+
<a-marker type='barcode' value='0'>
13+
<a-sphere position="0 0.5 0" radius="1" color="red" />
14+
</a-marker>
15+
16+
<a-entity camera></a-entity>
17+
18+
</a-scene>
19+
</body>

aframe/src/system-arjs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ AFRAME.registerSystem('arjs', {
3333
type: 'number',
3434
default: -1,
3535
},
36+
labelingMode: {
37+
type: 'string',
38+
default: '',
39+
},
3640
cameraParametersUrl: {
3741
type: 'string',
3842
default: '',
@@ -108,6 +112,7 @@ AFRAME.registerSystem('arjs', {
108112
if (this.data.detectionMode !== '') arProfile.contextParameters.detectionMode = this.data.detectionMode
109113
if (this.data.matrixCodeType !== '') arProfile.contextParameters.matrixCodeType = this.data.matrixCodeType
110114
if (this.data.patternRatio !== -1) arProfile.contextParameters.patternRatio = this.data.patternRatio
115+
if (this.data.labelingMode !== '') arProfile.contextParameters.labelingMode = this.data.labelingMode
111116
if (this.data.cameraParametersUrl !== '') arProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl
112117
if (this.data.maxDetectionRate !== -1) arProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate
113118
if (this.data.canvasWidth !== -1) arProfile.contextParameters.canvasWidth = this.data.canvasWidth

three.js/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ var parameters = {
5353
matrixCodeType: '3x3',
5454
// Pattern ratio for custom markers
5555
patternRatio: 0.5
56+
// Labeling mode for markers - ['black_region', 'white_region']
57+
// black_region: Black bordered markers on a white background, white_region: White bordered markers on a black background
58+
labelingMode: 'black_region',
5659

5760
// url of the camera parameters
5861
cameraParametersUrl: 'parameters/camera_para.dat',

three.js/src/threex/threex-artoolkitcontext.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ ARjs.Context = THREEx.ArToolkitContext = function (parameters) {
2929
// the patternRatio inside the artoolkit marker - artoolkit only
3030
patternRatio: 0.5,
3131

32+
// Labeling mode for markers - ['black_region', 'white_region']
33+
// black_region: Black bordered markers on a white background, white_region: White bordered markers on a black background
34+
labelingMode: 'black_region',
35+
36+
3237
// enable image smoothing or not for canvas copy - default to true
3338
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled
3439
imageSmoothingEnabled: false,
3540
}
3641
// parameters sanity check
3742
console.assert(['artoolkit', 'aruco'].indexOf(this.parameters.trackingBackend) !== -1, 'invalid parameter trackingBackend', this.parameters.trackingBackend)
3843
console.assert(['color', 'color_and_matrix', 'mono', 'mono_and_matrix'].indexOf(this.parameters.detectionMode) !== -1, 'invalid parameter detectionMode', this.parameters.detectionMode)
44+
console.assert(["black_region", "white_region"].indexOf(this.parameters.labelingMode) !== -1, "invalid parameter labelingMode", this.parameters.labelingMode);
3945

4046
this.arController = null;
4147
this.arucoContext = null;
@@ -234,6 +240,16 @@ ARjs.Context.prototype._initArtoolkit = function (onCompleted) {
234240
// set the patternRatio for artoolkit
235241
arController.setPattRatio(_this.parameters.patternRatio);
236242

243+
// set the labelingMode for artoolkit
244+
var labelingModeTypes = {
245+
"black_region": artoolkit.AR_LABELING_BLACK_REGION,
246+
"white_region": artoolkit.AR_LABELING_WHITE_REGION
247+
}
248+
var labelingModeType = labelingModeTypes[_this.parameters.labelingMode];
249+
console.assert(labelingModeType !== undefined);
250+
arController.setLabelingMode(labelingModeType);
251+
252+
237253
// set thresholding in artoolkit
238254
// this seems to be the default
239255
// arController.setThresholdMode(artoolkit.AR_LABELING_THRESH_MODE_MANUAL)

three.js/src/threex/threex-artoolkitprofile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ARjs.Profile.prototype.reset = function () {
4646
this.contextParameters = {
4747
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
4848
detectionMode: 'mono',
49+
labelingMode: "black_region"
4950
}
5051
this.defaultMarkerParameters = {
5152
type: 'pattern',
@@ -105,10 +106,12 @@ ARjs.Profile.prototype.defaultMarker = function (trackingBackend) {
105106
this.contextParameters.detectionMode = 'mono'
106107
this.defaultMarkerParameters.type = 'pattern'
107108
this.defaultMarkerParameters.patternUrl = THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
109+
this.contextParameters.labelingMode = "black_region"
108110
} else if (trackingBackend === 'aruco') {
109111
this.contextParameters.detectionMode = 'mono'
110112
this.defaultMarkerParameters.type = 'barcode'
111113
this.defaultMarkerParameters.barcodeValue = 1001
114+
this.contextParameters.labelingMode = "black_region"
112115
} else console.assert(false)
113116

114117
return this

0 commit comments

Comments
 (0)