Skip to content

Commit

Permalink
chore: image descriptor as pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Dec 2, 2023
1 parent ebea135 commit d85d711
Show file tree
Hide file tree
Showing 18 changed files with 1,072 additions and 230 deletions.
388 changes: 198 additions & 190 deletions 1.0/fidmark.ttl

Large diffs are not rendered by default.

File renamed without changes.
426 changes: 426 additions & 0 deletions examples/eswc2024_generator/data/virtual_objects.ttl

Large diffs are not rendered by default.

174 changes: 169 additions & 5 deletions examples/eswc2024_generator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions examples/eswc2024_generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "openhps-rdf -d ./src/ontologies -n fidmark:http://purl.org/fidmark/ -n omg:https://w3id.org/omg# -n fog:https://w3id.org/fog# -m http://purl.org/fidmark/ https://openhps.github.io/FidMark/1.0/ontology.ttl -m https://w3id.org/fog# https://mathib.github.io/fog-ontology/ontology.ttl"
"postinstall": "openhps-rdf -d ./src/ontologies -n fidmark:http://purl.org/fidmark/ -n omg:https://w3id.org/omg# -n fog:https://w3id.org/fog# -m http://purl.org/fidmark/ https://openhps.github.io/FidMark/1.0/ontology.ttl -m https://w3id.org/fog# https://mathib.github.io/fog-ontology/ontology.ttl",
"generate": "ts-node ./src/generator"
},
"author": "",
"license": "ISC",
"dependencies": {
"@openhps/core": "^0.6.4",
"@openhps/rdf": "^0.4.27",
"axios": "^1.6.2"
"@openhps/rdf": "^0.4.28",
"axios": "^1.6.2",
"ts-node": "^10.9.1"
}
}
97 changes: 97 additions & 0 deletions examples/eswc2024_generator/src/generator.ts
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();
Loading

0 comments on commit d85d711

Please sign in to comment.