DavidBoja / SMPL-Anthropometry

Measure the SMPL body model
MIT License
160 stars 22 forks source link

How to generate own json? #1

Closed angus2292 closed 1 year ago

angus2292 commented 1 year ago

Hi, I want to ask how you generate .json? Because SMPL's output is .obj. So, if i want to use my own data, how could i do?

DavidBoja commented 1 year ago

Hi,

In the main part of measure.py you can see how to generate the measurements:

https://github.com/DavidBoja/SMPL-Anthropometry/blob/6e21bef3e76b64ab7d3ec491d6f7e0381d37444c/measure.py#L721-L738

The measurer.measurements and measurer.labeled_measurements are python dictionaries of measurements, which you can convert easily to json.

To use on your own data, you can adapt the same snippet i shared above. If you want to initialize the body model with the vertices of an already fitted SMPL body model to your scan, you can use:

MeasureSMPL(...).from_verts(verts)

instead of

MeasureSMPL(...).from_smpl(betas, gender)

as it says in the README file.

angus2292 commented 1 year ago

thanks for answering. So, what kind of input data I need to have? I'm still get in trouble about this.

DavidBoja commented 1 year ago

There are two options for the input data:

  1. SMPL shape (called betas with dimension 1 x 10) and gender parameters. In this case you can initialize the measurer with:
    MeasureSMPL(...).from_smpl(betas, gender)
  2. SMPL body vertices (called verts, dimension 6890 x 3). In this case you can initialize the measurer with:
    MeasureSMPL(...).from_verts(verts)

In the first case your SMPL body is defined by its parameters, and in the second case it's defined with its vertices.

angus2292 commented 1 year ago

So, let me make a conclusion. If I want to use my own data, I need to have .obj file and fit the .from_verts function, right? If not, what kind of file type should I have. Sorry to bother you.

DavidBoja commented 1 year ago

Yes, that is one of the options. Having 6890 3D vertices from the .obj file that correspond to an SMPL model. Then you can use the .from_verts function.

No problem -- I refined the README file to hopefully make things a bit more clear. Checkout the Running section and let me know if there are more questions.

angus2292 commented 1 year ago

Thanks. I would try it

DavidBoja commented 1 year ago

Closing issue -- feel free to re-open if you will have further questions.