juangallostra / augmented-reality

Augmented reality proof of concept project with Python and OpenCV
MIT License
335 stars 118 forks source link

Size of loaded model and textures #6

Closed ShubhamJain7 closed 5 years ago

ShubhamJain7 commented 5 years ago

I tried loading a few models of my own but the loaded models are extremely tiny while models you have provided are of the perfect size. Is there any way to overcome this? Also, how do you go about loading textures?

Attaching a model that has this issue: dna.zip

juangallostra commented 5 years ago

Hi @ShubhamJain7

Re size model, there is this scale_matrix parameter here: https://github.com/juangallostra/augmented-reality/blob/ba7df7f9af85da7c9960dbff052a519d0af20983/src/ar_main.py#L103

That allows to resize the model and make it bigger. I had to tune it by hand until the models had the desired size. You should change the 3 there by a suitable number that renders your model correctly.

Re textures, take a look at this script https://www.pygame.org/wiki/OBJFileLoader which loads an OBJ file into an OpenGL display list with material properties and textures. It does require OpenGL though. The OBJ loader included in the repo is a simplified version that only loads vertex and face info.

ShubhamJain7 commented 5 years ago

Thank you! The re-sizing worked but I was hoping there would be a way to load textures without OpenGL or pygame.

juangallostra commented 5 years ago

@ShubhamJain7 sadly, I am not sure that's possible or, at least, I don't know an easy way to load textures without OpenGL. I mean, you could try to implement your own texture loader/renderer but I think it is not worth it unless you want to take it as a learning project.

ShubhamJain7 commented 5 years ago

Trying to implement my own texture loader would be a big detour for what I am trying to achieve. Think I will try and get it done with OpenGL itself.

juangallostra commented 5 years ago

@ShubhamJain7 should we close the issue then?

ShubhamJain7 commented 5 years ago

@juangallostra yes. I shall make a pull request if I am able to load textures.