Git Product home page Git Product logo

Comments (4)

shunsukesaito avatar shunsukesaito commented on May 12, 2024

Sorry for late response. If you are interested in generating point cloud, you can change the following line in lib/renderer/gl/data/prt.vs
VertexOut.Position = R * pos;
to
VertexOut.Position = pos;

Then you can directly obtain point cloud rendered from the input view by
get_color(self, color_id=2)
You can refer to lib/renderer/gl/data/prt.fs to see what attribute corresponds to which color_id.
Hope it helps.

from pifu.

LogWell avatar LogWell commented on May 12, 2024

After change VertexOut.Position = R * pos; to VertexOut.Position = pos; in lib/renderer/gl/data/prt.vs, and insert the following code in apps/render_data.py,

out_all_z = rndr.get_color(2)

v1, v2 = [], []
for ii in range(512):
    for jj in range(512):
        if out_all_z[ii, jj][3] != 0.0:
            p1 = out_all_z[ii, jj, :3] / y_scale + vmed
            v1.append(p1)

            X = (jj - 256) * cam.ortho_ratio
            Y = (256 - ii) * cam.ortho_ratio
            Z = - out_all_z[ii, jj, 3] * 100
            p2 = np.array([X, Y, Z]) / y_scale + vmed
            v2.append(p2)

v1 = np.array(v1)
v2 = np.array(v2)

with open('v1.obj', 'w') as fp:
    fp.write(('v {:f} {:f} {:f}\n' * v1.shape[0]).format(*v1.reshape(-1)))
with open('v2.obj', 'w') as fp:
    fp.write(('v {:f} {:f} {:f}\n' * v2.shape[0]).format(*v2.reshape(-1)))

I get the following results: a) is the original input mesh; b) is v1 overlaps on a); c) is the side view, they match perfectly; in d), the green one is v1, the blue point cloud is v2 (there is a little translation between them)

If I use out_all_z = rndr.get_z_value() in the first comment, I got the same result as v2.

I'm a little bit confused about these results, is there anything wrong about on calculation of v2, or the first way to calculate point cloud?

from pifu.

shunsukesaito avatar shunsukesaito commented on May 12, 2024

The output depth should be normalized to [0,1] corresponding to [zNear, zFar] in the original space. As zNear=-100 and zFar=100, your depth renormalization code seems incorrect to me.
How about
Z = - (out_all_z[ii, jj, 3]-0.5) * 200
?

from pifu.

LogWell avatar LogWell commented on May 12, 2024

In the first comment:
I use out_all_z = rndr.get_z_value() and Z = (1 - out_all_z[ii, jj] * 2) * (cam.far - cam.near) / 2, you can check it.

In the third comment:
I use out_all_z = rndr.get_color(2) and Z = - out_all_z[ii, jj, 3] * 100.

As your reply, the first comment was the way you wrote, but there is a little deviation from the input mesh. If I replace the third comment about Z, the result is wrong.

Thanks for quick reply~

from pifu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.