-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,072 additions
and
230 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { Quad, RDFSerializer, Store } from "@openhps/rdf"; | ||
import { ARTagMarker, ArUcoMarker, FiducialMarker, MarkerDictionary, VirtualObject } from "./models"; | ||
import { DICT_ARUCO_4X4_250 } from "./ontologies/fidmark"; | ||
import { Absolute3DPosition, AngleUnit, GeographicalPosition, LengthUnit, Orientation, Relative3DPosition, RelativeOrientation } from "@openhps/core"; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { ImageDescriptor } from "./models/ImageDescriptor"; | ||
|
||
const URI = "http://example.org/markers/"; | ||
|
||
function createArUco(): Quad[] { | ||
const store = new Store(); | ||
for (let i = 1 ; i < 4 ; i++) { | ||
const marker = new ArUcoMarker(); | ||
marker.uid = `marker-${i}`; | ||
marker.identifier = i * 21; | ||
marker.height = 4; | ||
marker.width = 4; | ||
marker.dictionary = MarkerDictionary.fromURI(DICT_ARUCO_4X4_250); | ||
marker.setPosition(new Absolute3DPosition(i * 19, i * 10, 0, LengthUnit.METER)); | ||
marker.position.setOrientation(Orientation.fromEuler({ | ||
yaw: 31, | ||
roll: 20, | ||
pitch: 12, | ||
unit: AngleUnit.DEGREE | ||
})); | ||
const quads = RDFSerializer.serializeToQuads(marker, URI); | ||
store.addQuads(quads); | ||
} | ||
return store.getQuads(undefined, undefined, undefined, undefined); | ||
} | ||
|
||
function createARTag(): Quad[] { | ||
const store = new Store(); | ||
for (let i = 4 ; i < 7 ; i++) { | ||
const marker = new ARTagMarker(); | ||
marker.uid = `marker-${i}`; | ||
marker.identifier = i * 21; | ||
marker.height = 5; | ||
marker.width = 5; | ||
marker.setPosition(new Absolute3DPosition(i * 19, i * 10, 0, LengthUnit.METER)); | ||
marker.position.setOrientation(Orientation.fromEuler({ | ||
yaw: 31, | ||
roll: 20, | ||
pitch: 12, | ||
unit: AngleUnit.DEGREE | ||
})); | ||
const quads = RDFSerializer.serializeToQuads(marker, URI); | ||
store.addQuads(quads); | ||
} | ||
return store.getQuads(undefined, undefined, undefined, undefined); | ||
} | ||
|
||
function createCustomMarker(): Quad[] { | ||
const store = new Store(); | ||
const marker = new FiducialMarker(); | ||
marker.uid = `marker-hiro`; | ||
marker.height = 5; | ||
marker.width = 5; | ||
marker.imageDescriptor = new ImageDescriptor(); | ||
marker.imageDescriptor.image = "https://arprojectsdemo.netlify.app/markers/hiro.png"; | ||
marker.imageDescriptor.pattern = "https://arprojectsdemo.netlify.app/data/hiro.patt"; | ||
const quads = RDFSerializer.serializeToQuads(marker, URI); | ||
store.addQuads(quads); | ||
return store.getQuads(undefined, undefined, undefined, undefined); | ||
} | ||
|
||
function createVirtualObjects(): Quad[] { | ||
const store = new Store(); | ||
for (let i = 1 ; i < 7 ; i++) { | ||
const object = new VirtualObject(); | ||
object.uid = `virtualobject-${i}`; | ||
//object.addRelativePosition(new RelativeOrientation(`marker-${i}`, 1, 1, 1, 1)) | ||
object.addRelativePosition(new Relative3DPosition(`marker-${i}`, 0, 0, 0, LengthUnit.METER)); | ||
const quads = RDFSerializer.serializeToQuads(object, URI); | ||
store.addQuads(quads); | ||
} | ||
return store.getQuads(undefined, undefined, undefined, undefined); | ||
} | ||
|
||
async function generate() { | ||
const store = new Store(); | ||
store.addQuads(createArUco()); | ||
store.addQuads(createARTag()); | ||
store.addQuads(createCustomMarker()); | ||
store.addQuads(createVirtualObjects()); | ||
const data = await RDFSerializer.stringify(store, { | ||
prettyPrint: true, | ||
prefixes: { | ||
example: URI, | ||
fidmark: "http://purl.org/fidmark/" | ||
} | ||
}); | ||
fs.writeFileSync(path.join("./data", "virtual_objects.ttl"), data); | ||
} | ||
|
||
generate(); |
Oops, something went wrong.