Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save the poses and map points? #7

Open
ghost opened this issue Sep 15, 2020 · 2 comments
Open

How to save the poses and map points? #7

ghost opened this issue Sep 15, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 15, 2020

How can I access the poses and map points information so that I can save them in a file?

@LaurensJN
Copy link

LaurensJN commented Oct 11, 2021

I didn't test this, but something like this should work for the map points. Just paste it and put it before the line sptam.stop():

for kf in sptam.graph.keyframes():
    for m in kf.measurements():
        if m.from_triangulation():
            pts.append([m.mappoint.position, m.mappoint.normal, m.mappoint.color])

with open('pointcloud.txt', 'w') as f:
    f.write('x,y,z,nx,ny,nz,r,g,b\n')
    for pt in pts:
        pos, n, rgb = pt
        f.write(','.join([str(el) for p in pos]))
        f.write(','.join([str(el) for p in n]))
        f.write(','.join([str(el) for p in rgb]))
        f.write('\n)

@shaoxh
Copy link

shaoxh commented Apr 11, 2023

You can follow this.
Some errors and tempos in codes by @LaurensJN , so I slightly modify it.

`
def stop(self):
self.mapping.stop()
if self.loop_closing is not None:
self.loop_closing.stop()
sptam.tracker.optimizer.save("tracker-optimizer.g2o")

    pts = list()
    for kf in sptam.graph.keyframes():
        for m in kf.measurements():
            if m.from_triangulation():
                pts.append([m.mappoint.position, m.mappoint.normal, m.mappoint.color])

    with open('pointcloud.txt', 'w') as f:
        f.write('x,y,z,nx,ny,nz,r,g,b\n')
        for pt in pts:
            pos, n, rgb = pt
            f.write(','.join([str(p) for p in pos]))
            f.write(',')
            f.write(','.join([str(p) for p in n]))
            f.write(',')
            f.write(','.join([str(p) for p in rgb]))
            f.write('\n')

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants