Closed felicks closed 3 years ago
yes you can track images dynamically. I'm assuming that firebase storage just gives you urls...
let image ='https://some image...'
ar.trackImage({
image: image,
width:1, //detection is much faster with defined widths (I seem to recall)
onDetectedImage: (args) => {
console.log('found image');
args.imageTrackingActions.addImage({
position: {
x: 0, y: -0.1, z: 0
},
image: fromFontIconCode("Hello World", new Font('FontAwesome', 100, 'normal', "100"), new Color("black"));
}).catch(console.error);
}
})
oops - sorry didn't mean to close this on you...
Thanks a lot @nickolanack. Unfortunatly I get the following error:
ERROR Error: 'trackImage' is only supported with trackingMode: IMAGE
here is my code:
<AR trackingMode="IMAGE"></AR>
ngOnInit(): void {
firebase.getValue('/components')
.then(result => (this.info = JSON.stringify(result.value)) )
.catch(error => console.log("Error: " + error));
setTimeout(() => { this.loaded = true; }, 1000);
let image ='https://images-na.ssl-images-amazon.com/images/I/61Qdz0MHRrL._AC_SX466_.jpg'
AR.prototype.trackImage({
image: image,
width:1,
onDetectedImage: (args) => {
console.log('found Fritzbox');
}
})
}
I'm pretty sure that calling trackImage like: AR.prototype.trackImage(...)
is the issue.
I think you need to capture the arLoaded event <AR (arLoaded)="arLoaded($event)" arLoaded></AR>
then use event.object as your AR instance. ie `event.object.trackImage(...)'
thanks for your help, works like a charm! Do you know if multiple images are supported? @nickolanack
Yes, you can track multiple images.
I couldn't get it working just by using an array of URLs. What did I do wrong?
you'll have to call .trackImage
for each image. ie:
someImageUrls.forEach((url)=>{
ar.trackImage({
image: url,
//...
});
});
Is it in some way possible to use dynamic images that are stored with firebase storage, as tracking image references? Or does it just workes with images that are stored in the App Resources folder?