jeromeetienne / AR.js

Efficient Augmented Reality for the Web - 60fps on mobile!
MIT License
15.79k stars 2.22k forks source link

Scale model based on QR code size #578

Closed ghost closed 5 years ago

ghost commented 5 years ago

When the mobile phone recognizes the QR code, the loaded model does not match the size of the QR code.

Can the model be set to the size of the QR code after successful recognition?

Is there any api I can use?

nicolocarpignoli commented 5 years ago

Hi, are you referring to QR Code or Marker?

droid001 commented 5 years ago

@kingov Shouldn't you just be setting the scale of the model to fit your needs? @nicolocarpignoli Is the marker a certain size like 1m2 when it is recognised or does it depend on the physical size of the marker?

ghost commented 5 years ago

because the model are not the same , so i can't scale model to fit qrcode .

ghost commented 5 years ago

i mean Marker

nicolocarpignoli commented 5 years ago

I try to summerize:

you cannot set (or at least, easily) the model to be great as the QR Code. This because the qr code recognization occur before the launch of the arjs web app.

If you want to make the model great as the marker, you can scale the model. You have to try and see how much to scale, it depends on initial size of the model.

@droid001 it depends on physical size of the marker, that is recognized from the camera: of course if the marker is 10x10cm but you are 10meters far, from the camera perspective the marker is tiny.

droid001 commented 5 years ago

I'm thinking in terms of units. Take for example the basic AR.js demo, the box has size of 1 on all sides var geometry = new THREE.CubeGeometry(1,1,1);. That would mean if you have a model which came out of a 3D rendering programme like Blender which base unit i 1m, then you could calculate the desired size of your model, which you know from the rendering programme, and the physical size of your marker. If you wanted a 1m3 cube to be represented in AR as it's physical size then for a 10cm marker you would have to increase the size of your cube by 10.